简体   繁体   English

使用意图过滤器恢复已暂停的活动?

[英]Resume paused activity with intent filter?

In my app I'm using twitter auth, and my activity at some moment of time opens a browser using startActivity(new Intent(Intent.ACTION_VIEW, "path to twitter")); 在我的应用程序中,我使用的是twitter auth,我的活动有时会使用startActivity(new Intent(Intent.ACTION_VIEW, "path to twitter"));打开浏览器startActivity(new Intent(Intent.ACTION_VIEW, "path to twitter")); to allow user to confirm access. 以允许用户确认访问权限。 Same activity has intent filter 同一活动具有意图过滤器

       <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="twconnect" android:host="success" />
        </intent-filter>

so when user confirms access, he is being redirected back to this activity. 因此,当用户确认访问权限后,他将被重定向回该活动。 But instead of just resuming previously paused activity, it creates a new one, calls onCreate and, I believe, creates new task with empty back stack. 但是,它不仅恢复了先前暂停的活动,还创建了一个新的活动,调用了onCreate而且我相信,它会创建一个具有空后栈的新任务。 Is there any way to resume paused activity in it's task? 有什么办法可以恢复任务中暂停的活动?

In this case, Android controls what activity will remain in Background or will be killed (if I'm not wrong). 在这种情况下,Android控制哪些活动将保留在后台或将被杀死(如果我没记错的话)。 If he needs more memory, it will kill the Activity and recreate when necessary. 如果他需要更多内存,它将杀死Activity并在必要时重新创建。 Try to pass and get your data in savedInstanceState . 尝试传递并在saveInstanceState中获取数据。 You should make a logic to control the state (if twitter were opened yet and continue the process) 您应该制定逻辑来控制状态(如果Twitter已打开并继续该过程)

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

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