Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.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 启动活动时获取java.lang.RuntimeException_Android_Android Intent_Android Activity_Launchmode - Fatal编程技术网

Android 启动活动时获取java.lang.RuntimeException

Android 启动活动时获取java.lang.RuntimeException,android,android-intent,android-activity,launchmode,Android,Android Intent,Android Activity,Launchmode,我有一个活动,A,当我想在她体内开始这个活动时,它是SingleTop,带有另一个意图数据,如下所示: Intent intent = new Intent(); intent.setData(Uri.parse("something://someone")); startActivity(intent); F/libc (24873): Fatal signal 11 (SIGSEGV) at 0x00007074 (code=1), thread 24939 (Thread-2287

我有一个活动,
A
,当我想在她体内开始这个活动时,它是
SingleTop
,带有另一个意图数据,如下所示:

Intent intent = new Intent();
intent.setData(Uri.parse("something://someone"));
startActivity(intent);
F/libc    (24873): Fatal signal 11 (SIGSEGV) at 0x00007074 (code=1), thread 24939 (Thread-2287)
I/DEBUG   (  195): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  195): Build fingerprint: 'google/occam/mako:4.4.2/KOT49H/937116:user/release-keys'
I/DEBUG   (  195): Revision: '11'
I/DEBUG   (  195): pid: 24873, tid: 24939, name: Thread-2287  >>> com.blah.blah <<<
I/DEBUG   (  195): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00007074
I/DEBUG   (  195):     r0 779b9828  r1 4199b380  r2 00000014  r3 00007075
I/DEBUG   (  195):     r4 76b24ac0  r5 00000014  r6 00000000  r7 779b9828
I/DEBUG   (  195):     r8 774c3afc  r9 76c84d90  sl 76da6250  fp 774c3b14
I/DEBUG   (  195):     ip 733e9cec  sp 774c3ac0  lr 40a49b9d  pc 00007074  cpsr 00070030
I/DEBUG   (  195):     d0  0000000000000000  d1  0000000000000000
I/DEBUG   (  195):     d2  0000000000000000  d3  0000000000000000
I/DEBUG   (  195):     d4  0000000000000000  d5  0000000000000000
I/DEBUG   (  195):     d6  0000000000000000  d7  0000000000000000
I/DEBUG   (  195):     d8  0000000000000000  d9  0000000000000000
I/DEBUG   (  195):     d10 0000000000000000  d11 0000000000000000
I/DEBUG   (  195):     d12 0000000000000000  d13 0000000000000000
I/DEBUG   (  195):     d14 0000000000000000  d15 0000000000000000
I/DEBUG   (  195):     d16 0000000000000000  d17 0000000000000000
I/DEBUG   (  195):     d18 4a9b4d1ae3550b44  d19 1619de72ef18c72c
I/DEBUG   (  195):     d20 a5598b5ef3ee9d2c  d21 ea73a9b3cbecc5ff
I/DEBUG   (  195):     d22 1f5becf8adc083d0  d23 3f09f8604410f094
I/DEBUG   (  195):     d24 4000000000000000  d25 547d42aea2879f2e
I/DEBUG   (  195):     d26 40f86a0000000000  d27 3ff0000000000000
I/DEBUG   (  195):     d28 40f86a0000000000  d29 0000000000000001
I/DEBUG   (  195):     d30 4024000000000000  d31 4000000000000000  
...  
Force finishing activity com.blah.blah.A
Intent intent = new Intent(this, newActivity.class);
出现此异常:

startActivityUncheckedLocked: task left null
V/ActivityManager(  596): java.lang.RuntimeException: here
V/ActivityManager(  596):   at com.android.server.am.ActivityStackSupervisor.startActivityUncheckedLocked(ActivityStackSupervisor.java:1646)
V/ActivityManager(  596):   at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1249)
V/ActivityManager(  596):   at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:741)
V/ActivityManager(  596):   at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:3118)
V/ActivityManager(  596):   at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:3104)
V/ActivityManager(  596):   at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:135)
V/ActivityManager(  596):   at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2071)
V/ActivityManager(  596):   at android.os.Binder.execTransact(Binder.java:404)
我该怎么办?我做错什么了吗

谢谢

编辑1
在我的
AndroidManifest.xml
文件中,我定义了
something://
以使用活动
A
打开

编辑2
当活动
A
不是
singleTop
时,没有问题

编辑3
此错误不会导致我的应用程序强制自己关闭,事实上,问题是,有时在收到此错误后,我会收到如下错误:

Intent intent = new Intent();
intent.setData(Uri.parse("something://someone"));
startActivity(intent);
F/libc    (24873): Fatal signal 11 (SIGSEGV) at 0x00007074 (code=1), thread 24939 (Thread-2287)
I/DEBUG   (  195): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  195): Build fingerprint: 'google/occam/mako:4.4.2/KOT49H/937116:user/release-keys'
I/DEBUG   (  195): Revision: '11'
I/DEBUG   (  195): pid: 24873, tid: 24939, name: Thread-2287  >>> com.blah.blah <<<
I/DEBUG   (  195): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00007074
I/DEBUG   (  195):     r0 779b9828  r1 4199b380  r2 00000014  r3 00007075
I/DEBUG   (  195):     r4 76b24ac0  r5 00000014  r6 00000000  r7 779b9828
I/DEBUG   (  195):     r8 774c3afc  r9 76c84d90  sl 76da6250  fp 774c3b14
I/DEBUG   (  195):     ip 733e9cec  sp 774c3ac0  lr 40a49b9d  pc 00007074  cpsr 00070030
I/DEBUG   (  195):     d0  0000000000000000  d1  0000000000000000
I/DEBUG   (  195):     d2  0000000000000000  d3  0000000000000000
I/DEBUG   (  195):     d4  0000000000000000  d5  0000000000000000
I/DEBUG   (  195):     d6  0000000000000000  d7  0000000000000000
I/DEBUG   (  195):     d8  0000000000000000  d9  0000000000000000
I/DEBUG   (  195):     d10 0000000000000000  d11 0000000000000000
I/DEBUG   (  195):     d12 0000000000000000  d13 0000000000000000
I/DEBUG   (  195):     d14 0000000000000000  d15 0000000000000000
I/DEBUG   (  195):     d16 0000000000000000  d17 0000000000000000
I/DEBUG   (  195):     d18 4a9b4d1ae3550b44  d19 1619de72ef18c72c
I/DEBUG   (  195):     d20 a5598b5ef3ee9d2c  d21 ea73a9b3cbecc5ff
I/DEBUG   (  195):     d22 1f5becf8adc083d0  d23 3f09f8604410f094
I/DEBUG   (  195):     d24 4000000000000000  d25 547d42aea2879f2e
I/DEBUG   (  195):     d26 40f86a0000000000  d27 3ff0000000000000
I/DEBUG   (  195):     d28 40f86a0000000000  d29 0000000000000001
I/DEBUG   (  195):     d30 4024000000000000  d31 4000000000000000  
...  
Force finishing activity com.blah.blah.A
Intent intent = new Intent(this, newActivity.class);
F/libc(24873):0x00007074(代码=1)处的致命信号11(SIGSEGV),线程24939(线程-2287)
I/DEBUG(195):*********************************************
I/DEBUG(195):构建指纹:“谷歌/occam/mako:4.4.2/KOT49H/937116:用户/发布密钥”
I/DEBUG(195):修订版:“11”

I/DEBUG(195):pid:24873,tid:24939,name:Thread-2287>>>com.blah.blah在您的意图中,您没有将类设置为启动。我的意思是你还没有定义要开始哪项活动

大概是这样的:

Intent intent = new Intent();
intent.setData(Uri.parse("something://someone"));
startActivity(intent);
F/libc    (24873): Fatal signal 11 (SIGSEGV) at 0x00007074 (code=1), thread 24939 (Thread-2287)
I/DEBUG   (  195): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  195): Build fingerprint: 'google/occam/mako:4.4.2/KOT49H/937116:user/release-keys'
I/DEBUG   (  195): Revision: '11'
I/DEBUG   (  195): pid: 24873, tid: 24939, name: Thread-2287  >>> com.blah.blah <<<
I/DEBUG   (  195): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00007074
I/DEBUG   (  195):     r0 779b9828  r1 4199b380  r2 00000014  r3 00007075
I/DEBUG   (  195):     r4 76b24ac0  r5 00000014  r6 00000000  r7 779b9828
I/DEBUG   (  195):     r8 774c3afc  r9 76c84d90  sl 76da6250  fp 774c3b14
I/DEBUG   (  195):     ip 733e9cec  sp 774c3ac0  lr 40a49b9d  pc 00007074  cpsr 00070030
I/DEBUG   (  195):     d0  0000000000000000  d1  0000000000000000
I/DEBUG   (  195):     d2  0000000000000000  d3  0000000000000000
I/DEBUG   (  195):     d4  0000000000000000  d5  0000000000000000
I/DEBUG   (  195):     d6  0000000000000000  d7  0000000000000000
I/DEBUG   (  195):     d8  0000000000000000  d9  0000000000000000
I/DEBUG   (  195):     d10 0000000000000000  d11 0000000000000000
I/DEBUG   (  195):     d12 0000000000000000  d13 0000000000000000
I/DEBUG   (  195):     d14 0000000000000000  d15 0000000000000000
I/DEBUG   (  195):     d16 0000000000000000  d17 0000000000000000
I/DEBUG   (  195):     d18 4a9b4d1ae3550b44  d19 1619de72ef18c72c
I/DEBUG   (  195):     d20 a5598b5ef3ee9d2c  d21 ea73a9b3cbecc5ff
I/DEBUG   (  195):     d22 1f5becf8adc083d0  d23 3f09f8604410f094
I/DEBUG   (  195):     d24 4000000000000000  d25 547d42aea2879f2e
I/DEBUG   (  195):     d26 40f86a0000000000  d27 3ff0000000000000
I/DEBUG   (  195):     d28 40f86a0000000000  d29 0000000000000001
I/DEBUG   (  195):     d30 4024000000000000  d31 4000000000000000  
...  
Force finishing activity com.blah.blah.A
Intent intent = new Intent(this, newActivity.class);


我也经历过这个错误。很抱歉,我的场景有点曲折,但如果它对这里的人有帮助,它是:

我有一个主要的活动,检查是否有额外的内容,以表明收到了通知。如果找到附加项,则转到ActivityA以显示通知,您可以单击按钮并转到ActivityB。我用了一种方法来为我做这个检查。到目前为止一切都很好

要结束ActivityB和ActivityA,从ActivityB中单击一个按钮将开始返回到MainActivity的意图,并带有FLAG_ACTIVITY_CLEAR_TOP和FLAG_ACTIVITY_SINGLE_TOP,一个la:

Intent intent = new Intent(ctx, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
一个疏忽是我在MainActivity的onResume()中调用了我的方法,对于我的一些调用来说,在生命周期中太早了。如果在onResume()中调用getIntent(),是否仍可能返回原始通知意图?无论如何,结果是ActivityB直接返回到MainActivity,而MainActivity又直接返回到ActivityA,因为它找到了多余的内容

我不确定哪一个错误是错误的根本原因,但如果您看到了,请考虑:

  • 您是否在活动的onResume()中调用了活动生命周期中太早的内容
  • 您是否正在开始一项活动,并将其返回到调用它的位置
  • 这是我的堆栈跟踪:

    startActivityUncheckedLocked: task left null
                                                 java.lang.RuntimeException: here
                                                     at com.android.server.am.ActivityStackSupervisor.startActivityUncheckedLocked(ActivityStackSupervisor.java:2965)
                                                     at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1935)
                                                     at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1043)
                                                     at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:4069)
                                                     at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:3963)
                                                     at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:159)
                                                     at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2638)
                                                     at android.os.Binder.execTransact(Binder.java:404)
                                                     at dalvik.system.NativeStart.run(Native Method)
    

    在我的AndroidManifest.xml文件中,我定义了一些:/,以便用活动A打开。我认为可以。为什么不可以?它是Intent类的公共构造函数,我找不到对其使用的任何限制。你能告诉我为什么不应该使用它吗?如果ActivityManager抛出一个RuntimeException,它总是一个Android bug。