Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 当从SherlockFragment启动新的意图活动时,应用程序自动终止_Android_Android Intent_Android Fragments - Fatal编程技术网

Android 当从SherlockFragment启动新的意图活动时,应用程序自动终止

Android 当从SherlockFragment启动新的意图活动时,应用程序自动终止,android,android-intent,android-fragments,Android,Android Intent,Android Fragments,当我称之为夏洛克碎片中的星际触觉时 Intent browse = new Intent(Intent.ACTION_VIEW , Uri.parse("URL"); startActivity( browse ); android默认浏览器启动正常,但我的应用程序的主要活动消失了(称为onStop事件)。当我按back返回到堆栈中的SherlockFragment时,应用程序将从初始状态而不是从最后一个活动片段状态重新启动。也许android应用程序生命周期可以帮助您找出问题所在。当一个活动

当我称之为夏洛克碎片中的星际触觉时

Intent browse = new Intent(Intent.ACTION_VIEW , Uri.parse("URL");
startActivity( browse );

android默认浏览器启动正常,但我的应用程序的主要活动消失了(称为onStop事件)。当我按back返回到堆栈中的SherlockFragment时,应用程序将从初始状态而不是从最后一个活动片段状态重新启动。

也许android应用程序生命周期可以帮助您找出问题所在。当一个活动处于暂停或停止状态,而另一个活动需要太多内存时,暂停的活动进程将被终止,当用户返回时,它将从onCreate方法重新开始,这将解释为什么您总是返回初始状态。将数据保存在onStop中的外部存储器上,然后在onCreate中验证是否有要检索的数据。希望这有帮助


活动管理器管理活动实例的方式(返回上一个,创建一个新实例…)可以使用您为您的意图指定的标志进行自定义,您应该仔细研究。例如,这一个就是一个完美的示例: