Issue
My app has a share intent that allows users to share text from another app to my app. When they do this, the app opens/shows and does something. I now want the back button to take users back to the app that they came from.
I know I can do this by adding finish() to onBackPressed(), but I don't want my app to close. If a user later taps to open the app, it should be where it left off.
As an example of this working, if you click a URL in Google Keep and choose "open" it opens Chrome. If you then use the Back Button, it takes you back to the Keep app. Chrome doesn't close, just the one opened tab closes.
Solution
KOTLIN (first):
//Activities
moveTaskToBack(true)
//Fragments
requireActivity().moveTaskToBack(true)
Java:
//Activities
moveTaskToBack(true);
//Fragments
getActivity().moveTaskToBack(true);
This will result in your application moving backwards
Answered By - Thatta Systems
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.