Here is the my subclass of Application

public class MyApp extends Application {
private HashMap<String, Boolean> selectedContacts = null;
 public HashMap<String, Boolean> getSelectedContacts() {
return this.selectedContacts;
}

public void setSelectedContacts(HashMap<String, Boolean> sc) {
this.selectedContacts = sc;
}
}


Below are the methods onActivityResult() and onClick() in my Messenger 
Activity.  In onActivityResult(), I set the private member variable of the 
MyApp Class.  In the onClick() method, I call the accesseror method.

public void onActivityResult(int reqCode, int resultCode, Intent data) {
super.onActivityResult(reqCode, resultCode, data);

switch (reqCode) {
case R.integer.contact_manager:
 if (resultCode == RESULT_CANCELED)
Log.d(getString(R.string.debug_tag), "FAILURE");
if (resultCode == RESULT_OK) {
Log.d(getString(R.string.debug_tag), "SUCCESS");
 MyApp appState = ((MyApp)getApplication());

appState.setSelectedContacts((HashMap<String, Boolean>) data
.getSerializableExtra("selectedContacts"));

 }
 break;
}
}


add_contact_button.setOnClickListener(new OnClickListener() {
>
> public void onClick(View v) {
>
>
>> Intent i = new Intent(Messenger.this, ContactManager.class);
>
>  MyApp appState = ((MyApp)getApplication());
>
> HashMap<String, Boolean> sc = appState.getSelectedContacts();   
>
>  
>
>                                 if (sc != null) {
>
> int totalContacts = sc.size();
>
> if (totalContacts > 0) {
>
> Bundle bundle = new Bundle();
>
> bundle.putSerializable("selectedContacts",
>
> sc); 
>
> i.putExtras(bundle);
>
> }
>
> }
>
> startActivityForResult(i, R.integer.contact_manager);
>
>
>> }
>
> });
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to