I have 3 activities which a BroadCast Receiver start. I want to check in BroadCast Receiver the 3 activities that which one was the last one finished and the second finished and then run the third activity. And do check all the time before starting an activity. Please help me how to resolve this issue.
You can do it using SharedPreferences
. When an activity is about to finish, write this event in the SharedPreferences
. In the BroadcastReceiver
, check this event.
PS: Let me know if you need more details on how to use it.
Make one satic counter for increment
Static int counter_Activity=0;
Do for all Three Activity
counter_Activity++;
finish();
pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
editor = pref.edit();
editor.putString(counter_Activity,Activity_name);
editor.commit();
For Checking in Brodcast Class.
pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
pref.getInt(1,Activity_name-1);
pref.getInt(2,Activity_name-2);
pref.getInt(3,Activity_name-3);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.