When clicking my notification, it opens the activity once and works fine, but then the notification remains in the message tray and doesn't open anything again.
Is there a way to set up the notification to open the activity every time the user clicks on it? Or is this not feasible with Android?
Thanks!
try to put launch mode to activity which you are trying to open from notification.Link will provide description about launch mode
<activity
android:name=".SingleTaskActivity"
android:label="singleTask launchMode"
android:launchMode="singleTask">
Helpful link for Launch mode
Related
I have 4 Activities: Launcher, MainActivity(SingleTask), NotificationActivity, ExampleActivity.
When the user clicks on the notification, NotificationActivity opens then ExampleActivity and finishes the NotificationActivity.
When I press back MainActivity opens. Now if I press back, the application gets closed. If the user then opens the app from the recent Tasks, NotificationActivity opens then ExampleActivivty. But if the user opens the app from the icon, Launcher Activity opens then MainActivity.
How to handle this situation?
Exactly this problem is covered in my answer to this question:
Remove data from notification intent
When you select your app from the list of recent tasks, Android remembers how the app was originally launched (in your case, via Notification) and starts the app again the same way. This can be considered a bug or a a feature, depending on what you expect to happen.
I've got a few suggestions in my answer that you can use to deal with it.
Related to: Android Messaging, Email app behavior when starting app from a link
To be able to start my app from an SMS, and then upon hitting the Messaging icon, have Messaging go back to where it was before (at the message showing the link), I added this to the manifest:
<activity android:name=".SMSActivity" android:launchMode="singleTask" >
But now when I do this, my app starts up great the first time I click the link in the SMS. If I then go back to Messaging and click the same link, my app is started, but with a completely black screen.
It seems I can't have it both ways. Changing the launchMode to singleTop fixes this problem, but if I do that, then if I launch the app from the SMS, my app takes over the Messaging app. The Recent list shows only the Messaging app running my app. I can't go back to Messaging.
There must be a way to get this to work. I have tried many combinations of launch modes in the manifest, and intent flags when starting up SMSActivity. Currently I am just using default flags when starting SMSActivity. I am not adding any flags to the Intent.
Thanks
I am developing an application in that I want to open url(www.google.com) with android default browser(com.android.browser). After some time I want to close or hide the browser and show my application to the user. I tried the following
Broadcast Receiver
Timer
Handler
None of them is working.
FYI -- I am starting the browser from fragment. I want to show the same fragment after closing or hiding the browser. The broadcast receiver is working but it is opening the initial fragment but I want the same fragment when I start the browser.
Please any one help me
I am developing an app that is having function to upload images to instagram. So when i upload the image to instagram and press the home button,the app is closed and when i ma relaunching the app it is starting from the main[ splash screen] activity.
In that application i am having option to take images from gallery and the camera. So when i press the home button and relaunch the app it should start the activity where i can chose the images.
I have tried a lot. If anyone have the solution please help me out.
By default last activity will open when relaunch the app.But some device it will not happen.
I don't know the proper reason but may there is settings problem in that device.
By default the last activity will be shown when the app is restarted. Unless you have added any 'no history flag' or:
android:noHistory="true"
Set noHistory to false. ..
I am working with Bluetooth Chat sample code. In sample app the Device opens up in another screen but I have implemented the same code with the difference that DeviceListActivity is called as soon as the app is started but this opens it in another screen and I want that it should be opened as pop-up in Bluetooth chat sample code.
Can someone let me know how to open Activity as pop-up?
in your manifest file, set your activity theme to dialog
<activity android:theme="#android:style/Theme.Dialog">