简体   繁体   中英

How to back to last app from recent list without finishing activity

I'm working on an application that connects to a server on a computer, it's about sharing a clipboard, links, etc. I added the activity responsible for sending to the sharing menu so you can send links directly from the browser and here is the problem. When user select my app I want the activity to be created, sent a link and returned to the browser but without finishing activity. I want to achieve an effect similar to open recent apps list and select previous app but programmatically.

I tried finish() and onBackPressed() but they close the activity

Finish() will close the activity, as it is it's role. But onBackPressed() should just call onPause. If the activity is killed by onBackPressed() (you should check if onDestroy() is actually called by, for example, overriding it and printing something), then it's possible that you are assigning a flag during the creation of activity that forces it to close later. Can you provide the code that shows the part where you create your activity?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM