Calling method from another class of first class

statbat

Lurker
Hi All,

I am learning android and am stuck somewhere.
I kindly need your help.

Please help.

Let me explain the problem.

I have a class called SMSSender which extends Activity.
Now in this class upon clicking a Contact Label, a ListView opens up that loads contacts from remote database using JSON

Now my problem is that upon selection of a particular contact i want to pass values to the SMSSender and not just pass values (that is easy part) i also want to trigger a function so that other process can happen.

SMSSender extends Activity:
Code:
    public void showPhoneList (View view){
        
        setStatusText("Loading contact list. Please wait...");

        
        Intent myIntent = new Intent();
        myIntent.setClassName("com.kat.SMSSender", "com.kat.SMSSender.PhoneList");
        startActivity(myIntent);
        
        
    }
This function opens the ListView class PhoneList

Now PhoneList class which extends ListActivity

Code:
lv.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
        
        Intent myIntent2 = new Intent();
        myIntent2.setClassName("com.kat.SMSSender", "com.kat.SMSSender.SMSSender");
        myIntent2.putExtra("com.kat.SMSSender.phonePos", position); // key/value pair, where key needs current package prefix.
        myIntent2.putExtra("com.kat.SMSSender.phoneName", ((TextView) view).getText().toString());
        startActivity(myIntent2);

        // Here basically i want to call SMSSender class's function 
        
        // Hide the application
        setVisible(false);
        
        // When clicked, show a toast with the TextView text
        Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
        }
    });
I have tried to call my desired functions in onNewIntent() but it does not work still.

Any help is highly appreciated.

Thanks
 
Top