How to pass an array list from one activity to another without starting it

前端 未结 4 1867
没有蜡笔的小新
没有蜡笔的小新 2021-01-06 18:31

I have an activity which has an array list

ArrayList array = new ArrayList(); 

i want this array list to be pa

4条回答
  •  無奈伤痛
    2021-01-06 18:45

    you can pass an intent to already running activity.. follow this http://www.helloandroid.com/tutorials/communicating-between-running-activities for that in the intent you can add an extra like this

    Intent contactsIntent = new Intent(getApplicationContext(),
                    ContactCards.class);
            contactsIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                    appWidgetId);
    //Bundle containing the serialized list
            Bundle extraContacts = new Bundle();
    //Putting the array list templist is the array list here
    
            extraContacts.putSerializable("CONTACT_KEY", tempList);
            extraContacts.putString("CALL_STRING", CALL_STRING);
            contactsIntent.putExtras(extraContacts);
            contactsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(contactsIntent);
    

提交回复
热议问题