如何从 Android 中的应用程序恢复之前正在运行的应用程序?
给我一点指导: 因为我的应用程序正在使用广播接收器运行,并且每当我的应用程序在后台并且任何传入事件发生时,它都会触发我的应用程序。
现在我们想要当我们收听或播放一些视频文件或在 Android 手机上浏览时 随着传入事件的发生和我的应用程序的启动(已经在后台运行), 如果我将忽略该事件,我们想返回之前正在运行的任务(例如浏览、播放 视频文件应用),我们如何实现?
现在我正在使用 在触发 Event 之前存储正在运行的应用程序包和 Activity 信息,在使用完此信息后我们恢复 Activity 并 它工作正常,但仅与图库应用程序一起播放视频文件不正常,它会导致应用程序崩溃并重新启动图库应用程序。
请给我一些宝贵的积分来弥补?
通话结束后,上一个应用程序恢复(播放媒体文件),但下次时 在获取广播意图并尝试启动 Activity 时,该 Activity 未启动 和应用程序本身崩溃。
Give me a little guidance:
as My Application is running with Broadcast Receiver and when ever my application in Background and any incoming event comes it triggers the my Application.
Now we want as We are listening or playing some video file or browsing on Android Phone
and with incoming event occur and my application launch(already running in Background),
If i will ignore the event , we want to go back previous running task (Like browsing, playing
video file application), How we can achieve?
Now I am using The store the running application package and Activity info before triggering the Event , and after finishing using this info we resuming the Activity and
It working fine but Only with Gallery Application Playing of Vedio file is not fine , It Crashes the Application and relaunch the Gallery App.
Please give me some Valuable points to make it up?
On calling finish, Previous application resume(Playing of Media file) but when next time
on getting broadcast intent and try to launch the Activity , The Activity is not launching
and application itself crashing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过很长一段时间,我的问题得到了解决,我们只需要使用这个 api
moveTaskToBack(true);
并自动恢复之前正在运行的任务(例如浏览器、媒体应用程序或任何东西)
After a long back I got solution of my problem and we need only use to this api
moveTaskToBack(true);
and automatically resumes the previous running task(like browser, media application or any thing)
您是否尝试通过以下方式启动活动:
当您在活动中调用 finish() 时,您应该返回前一个活动,我不确定这是否会在不同应用程序中运行的活动之间起作用。尝试一下:D
Have you tried to start you activity by
When you call finish() in the Activity you should return the the previous one, I am not sure if this will function over between Activity running in different applications. Give it a try :D