相机或画廊意图破坏在某些设备上老年活动 [英] Camera or Gallery intent destroys old activity on some devices

查看:115
本文介绍了相机或画廊意图破坏在某些设备上老年活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的应用程序,它使用的WebView来显示其内容。但是,它需要以选择的图片打开相机或画廊:

I am working on app which uses WebView to display its content. However, it needs to open camera or gallery in order to choose picture:

    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    startActivityForResult(cameraIntent, 1);

    Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    startActivityForResult(galleryIntent, 2);

它的正常工作在大多数的设备,但在HTC One和其他几个人既意图破坏我的活动,因此,尽管回去的WebView被重新加载。我没有 noHistory 标志的Andr​​oidManifest.xml 。什么可能导致这个问题?我能避免在这里破坏我的活动?

It's working fine on most devices, but on HTC One and few others both intents destroys my activity, so webview is being reloaded while going back. I don't have noHistory flag in AndroidManifest.xml. What might be causing that issue? Can I avoid destroying my activity here?

推荐答案

这是通常情况下,机器人杀死你的活动时,其他应用程序运行。

It is normally, that Android kills your Activity when other app runs.

您必须保存活动状态的onSaveInstanceState和onRestoreInstanceState还是在的onCreate时,活动将被重新恢复状态。

You must save Activity state in onSaveInstanceState and when activity will be recreated restore state in onRestoreInstanceState or in onCreate.

要恢复的WebView的状态,您可以使用cookie和session和上次保存打开的网址。当活动将被重新只是导航的WebView上次保存从相机URL和处理结果。

To restore state of WebView you may use cookies and sessions and save last opened url. When activity will be recreated just navigate WebView last saved url and process result from camera.

这篇关于相机或画廊意图破坏在某些设备上老年活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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