启动媒体意图时,Android系统会停止应用 [英] Android system stops application when launching Media Intent

查看:147
本文介绍了启动媒体意图时,Android系统会停止应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我推出一个媒体的意图拍摄照片。在用户拍了一张照片,再返回到previous活动的整个应用程序重新启动。

I am launching a media intent to take a photo. After the user took a picture and gets back to the previous activity the whole application has restarted.

由于不会发生这种情况的时候,我想我的应用程序转到后台和Android杀死它时,该器件具有低内存。

As this doesn't happen all the time, I think my application goes to the background and android kills it when the device has low memory.

有什么办法让我的应用程序,从去到后台?

Is there any way to keep my application from going to the background?

谢谢!

推荐答案

这是在Android的正常行为,一切活动目前不可见的屏幕上(后的onStop )可杀死,恕不另行通知(即 onDestory )如果系统内存不足。

This is normal behavior in Android, all activities currently not visible on screen (after onStop) can be killed without notice (i.e. onDestory) if the system has low memory.

这通常发生在我们的应用程序对我们的测试设备的其中一个有记忆的问题,无论我们的应用程序中。

This usually happens to our app on one of our test devices which has memory issues regardless of our app.

您可以一般当你通过故意打开摄像头,然后旋转设备(纵向到横向)重建这种行为,这也将杀死并重新创建你的应用程序。

You can usually recreate this behavior when you open the camera via the intent, and then rotate the device (portrait to landscape), this will also kill and re-create your app.

要解决这个问题,你需要扩展的onSaveInstanceState 并使用了 savedInstanceState 参数的的onCreate 从你杀的实例传递给你的新实例一些重要的信息(如我们是在从相机获得一个事先知情同意的中央)。

To solve this you need to extend onSaveInstanceState and use the savedInstanceState parameter in your onCreate to pass from your killed instance to your new instance some important information (like "we're in the middle of getting a pic from the camera").

这篇关于启动媒体意图时,Android系统会停止应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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