I want to remove app from the recents. I have used android:excludeFromRecents="true" in manifest file.
So, whenever i click on home button, app is not present in recent list.
But when i open app, and click on recents, app will be part of recent apps list and it is accessible.
Is there any way to remove (or restrict app being part of recents) app when user click on recent when app was open.
Related
An issue is about that a launcher activity reopens when it is put into background and restored to foreground by clicking launcher. This problem occurs only after first run when a user installs an app and launch it from a play store or an android package installer.
Here are steps to reproduce the issue:
The user installs the app from the play store or android package installer;
After installation the user opens the new installed app by clicking “OPEN” inside the play store app or the android package installer;
Inside the app the user goes to another activity and put the whole app into background by pressing a home button;
The user restored the app from background by clicking the app icon and new launcher activity is created.
In a result there are 3 activities instead of 2. Back stack looks like this:
Launcher activity;
Some other activity which was started by user inside the app;
Launcher activity.
Next, when the app is removed from a recent apps` list and above steps are performed again then the app behaves exactly as expected. New back stack looks like this:
Launcher activity;
Some other activity which was started by user inside the app.
I created example app to demonstrate the issue:
source code
Here is shown installation process and a first run from the android package installer:
first run
The user starts a SecondActivity inside of the app and puts app into background. Next, the user want to restore the app back to foreground and it turns out that a FirstActivity was created again.
Here is a back stack after above steps:
back stack after first run
Now, lets run the app in standard way:
normal run
Before this test the app was removed from recent apps` list. The user starts the SecondActivity inside of the app and puts it into background by pressing home button. Next, the user restores the app back to foreground and this time the user sees the SecondActivity. The app behaves as expected now.
Here is the back stack after above steps:
back stack after normal run
The issue doesn’t refer only to my example app. It can be verified using any app from the play store. I did such test on a Netflix app which was installed from the play store (btw. the Netflix home screen isn’t visible due to security policy):
netflix first run
Here are steps:
Install the Netflix app;
Open it from the play store;
Click “HELP” button on a main screen (inside the Netflix app);
Put app into background;
Click app icon;
The user sees again the main screen instead of a help screen. The back stack looks like this:
Main screen;
Help screen;
Main screen.
It can be verified by pressing back button then the user will see each screen one by one. As we can see the Netflix app behaves identical as my example app.
Can someone explain to my why does it happen?
Is there a way to determine whether an Android app (main activity) was started by tapping its icon on the Home Screen, or from other places (such as the App Drawer, or even the Open button in the Google Play Store app)?
I need do do this in Java code, preferably in a method such as OnCreate.
For android apps, once it's started, it always run until manually closed. You can press the history button to see whether the app that you are interested is there. If it is, it means that it's running in the background.
I don't think there's a way to tell whether the app is running from Home Screen ... etc.
I would like the distinguish the event where a user resumes my app from the "recent apps" list, or from the launcher icon again even if there is an unfinished app running in the background.
My app is a single Activity containing multiple Fragments, the intended behavior is that if the user resumes from "recent apps", I wouldn't have to do anything as the default behavior brings them back to the fragment they left it at. However, when the user launches the app from the icon again, I want to pop all the fragments in my fragment manager to the first fragment, essentially behaving as if starting the app fresh.
Right now though, even if the user taps on the launcher icon, the app will be resumed as usual like from the "recent apps" list without onCreate() being called on the Activity.
I've looked at similar questions, but they seem to indicate that the activity DOES get recreated when the user launches from the icon again, which is weird and not what I observe: Android resume app from recent applications list
Any ideas?
You can try adding this attribute to your manifest file for your activity.
<activity>
...
android:launchMode="singleTask"
</activity
1.install an apk from app installer
2.then just click "OPEN" to launch it at once
3.after the app launched and then press HOME key
4.find the app from app list and click its icon to launch again
5.then the app will be launched with a new instance.
And if you repeat 3~5 several times, it will repeat create a new instance. if you press "BACK" key now, you will see the app is still there for the same times you launched.
But if you just click "DONE" at step 2 and then launch the app from app list, everything will be OK then.
Why?
The app installer (as well as many Android IDEs) use different intent flags than the regular app launcher does, which means that the launcher's intent doesn't properly match with the Activity's existing intent and it ends up creating a new activity on top of the stack.
I think this question is similar to what you're asking about:
Activity stack ordering problem when launching application from Android app installer and from Home screen
I'm writing a custom launcher app. The problem is even after setting it as default, the long press of HOME button brings recent app list, including old launcher.
Is it possible to clear the recent app list?