1. Introducing Channels - a new way to chat with other Android users!
    Dismiss Notice

Calling method from another class of first class


Last Updated:

  1. statbat

    statbat New Member This Topic's Starter

    Joined:
    Oct 22, 2010
    Messages:
    1
    Likes Received:
    0
    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 (Text):
    1.     public void showPhoneList (View view){
    2.        
    3.         setStatusText("Loading contact list. Please wait...");
    4.  
    5.        
    6.         Intent myIntent = new Intent();
    7.         myIntent.setClassName("com.kat.SMSSender", "com.kat.SMSSender.PhoneList");
    8.         startActivity(myIntent);
    9.        
    10.        
    11.     }
    This function opens the ListView class PhoneList

    Now PhoneList class which extends ListActivity

    Code (Text):
    1. lv.setOnItemClickListener(new OnItemClickListener() {
    2.     public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
    3.        
    4.         Intent myIntent2 = new Intent();
    5.         myIntent2.setClassName("com.kat.SMSSender", "com.kat.SMSSender.SMSSender");
    6.         myIntent2.putExtra("com.kat.SMSSender.phonePos", position); // key/value pair, where key needs current package prefix.
    7.         myIntent2.putExtra("com.kat.SMSSender.phoneName", ((TextView) view).getText().toString());
    8.         startActivity(myIntent2);
    9.  
    10.         // Here basically i want to call SMSSender class's function
    11.        
    12.         // Hide the application
    13.         setVisible(false);
    14.        
    15.         // When clicked, show a toast with the TextView text
    16.         Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
    17.         }
    18.     });
    I have tried to call my desired functions in onNewIntent() but it does not work still.

    Any help is highly appreciated.

    Thanks
     

    Advertisement

Share This Page

Loading...