安卓:恢复由previous位置的应用程序 [英] Android: resume app from previous position

查看:83
本文介绍了安卓:恢复由previous位置的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何才能恢复我的应用程序从previous位置。

How can I resume my app from its previous position.

请注意,它仍然是活动的,只是暂停。所以,如果我点击机器人当前应用程序按钮,或应用程序图标将恢复正常。

Note that it is still active, just paused. So if I click the androids current app button, or the app icon it resumes fine.

但谁做到这一点从我的窗口小部件。

But who do I do this from my widget..

我有以下几点:

// Create an Intent to launch Activity
Intent intent = new Intent(context, LoginForm.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);

这明显启动,而不是仅仅恢复应用程序的LoginForm的。

This obviously launches the LoginForm as opposed to just resuming the application.

有谁知道如何做到这一点?

Does anyone know how to do this?

编辑:

只是为了澄清,我不想要什么特别。我基本上想模仿pressing Android的图标启动程序。

Just to clarify, I dont want anything special. I basically want to mimic pressing the android icon launcher.

推荐答案

您已经基本上回答了你自己的问题; - )

You've basically answered your own question ;-)

只是模拟,当你启动应用程序的Andr​​oid做什么:

Just simulate what Android does when you launch the app:

Intent intent = new Intent(context, LoginForm.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);

或者你可以试试这个(假设 LoginForm的是应用程序的根系活力,并且有本次活动的一个实​​例仍然在任务堆栈主动):

or you could try this (assuming LoginForm is the root activity of your application and that there is an instance of this activity still active in the task stack):

Intent intent = new Intent(context, LoginForm.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);

设置 FLAG_ACTIVITY_NEW_TASK 只是把从后台到前台申请一个已经存在的任务,而不实际创建活动的一个实​​例。先试试这个。如果它不为你工作,做其他。

Setting FLAG_ACTIVITY_NEW_TASK should just bring an exising task for the application from the background to the foreground without actually creating an instance of the activity. Try this first. If it doesn't work for you, do the other.

这篇关于安卓:恢复由previous位置的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆