Aerrow
Aerrow

Reputation: 12134

How to implement Android BroadcastReceiver

I created a sample application. In my application I have 4 Activitys and 1 BroadCastReciever that runs in background. Here I wrote there service for the purpose of when the user Unlock the screen, I run my application. Everything works fine except this:

When I run my application, I'm in my third activity. The user no longer interacts with screen so the device gets auto screen locked. Now I unlock the screen means, the application runs from the first activity. I need to run the application from the user's last interacted activity (for example, if the user interacted with the third activity, I need to show the third activity when the screen unlocks).

Upvotes: 2

Views: 87

Answers (2)

Ramesh Maldakal
Ramesh Maldakal

Reputation: 3422

Do not finish the activity when you are moving from one activity to another activity and add WAKE_LOCK permissions in android manifest file

Upvotes: 1

Code Droid
Code Droid

Reputation: 10472

No problem, use SharedPreferences and store a currentActivityName. Update this when you enter a new Activity via onCreate or onStart(). This value will be preserved, even when the app shuts down. Once you detect your entry point you would just startActivity(activityName) once the app returns.

Upvotes: 1

Related Questions