Reputation: 1726
I am trying to learn android programming. I have made a basic app. It has a main activity, a settings activity and a notification that opens the settings activity on click. Main activity also has a settings button that opens settings activity. It may sound weird but i am trying to learn only. So the problem is when i open the settings activity and then click notification, it again opens settings activity on each click on notification. Then when i hit back button on my phone, it takes me again to settings activity and i have to press back button as many times as i clicked the notification to go back to main activity. Looks like the settings activity is being instantiated again and again on each click on notification. I have tried using many things i read online like trying some Intent flags but can't find anything working. I tried using finish(); in onBackPressed in my settings activity but doing this takes me to main activity and when i hit back on main activity, it takes me to settings and then again i have to hit back that number of times.
How do i make the notification open the settings activity only if its not running?
Upvotes: 0
Views: 168
Reputation: 48592
I think this can help you.
Edit in AndroidManifest.xml
<activity android:name=".SettingActivity" android:launchMode="singleTask">
This will open the activity if its not running.
Upvotes: 1