简体   繁体   English

如何在没有完成活动的情况下从最近的列表返回上一个应用

[英]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()onBackPressed()但他们关闭了活动

Finish() will close the activity, as it is it's role. Finish()将关闭活动,因为它是它的角色。 But onBackPressed() should just call onPause. 但onBackPressed()应该只调用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. 如果活动被onBackPressed()杀死(你应该检查onDestroy()是否实际被调用,例如,覆盖它并打印某些内容),那么你可能会在创建活动期间分配一个标志,强制它稍后关闭。 Can you provide the code that shows the part where you create your activity? 您能否提供显示您创建活动的部分的代码?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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