startActivity(intent)在某些设备中不起作用 [英] startActivity(intent) doesn't work in some devices

查看:562
本文介绍了startActivity(intent)在某些设备中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,对于该错误,我在Google上搜索了很多,但找不到任何能帮助我解决此问题的东西...因此,如果重复出现此问题,请原谅我.

First of all, I have Googled a lot for this error, and I couldn't find nothing that helps me to fix this problem... so, if this question is duplicated, forgive me.

我在遇到一个奇怪的错误时遇到了一些麻烦...我正在开发针对android minSdkVersion 14的应用程序.我在模拟器,HTC,三星Galaxy S2和Nexus 4中测试了我的应用程序该应用程序在所有这些设备中的行为都完全相同,但它简单地在Samsung GT-S6810中不起作用.

I'm having some trouble with a strange error... I'm developing an app that targets a android minSdkVersion 14. I tested my app in the emulator, in a HTC, a Samsung Galaxy S2 and also a Nexus 4. The app have the exactly same behavior in all this devices, but it simple doesn't work in a Samsung GT-S6810.

我检查了Logcat的应用程序,没有任何错误,但是如果我检查了整个日志,我会得到:

I checked the Logcat for my app and there's no error, but if I check the entire log, I get this:

02-10 19:39:03.640: E/ActivityManager(1565): Activity Manager Crash
02-10 19:39:03.640: E/ActivityManager(1565): java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
02-10 19:39:03.640: E/ActivityManager(1565):    at java.util.ArrayList.get(ArrayList.java:306)
02-10 19:39:03.640: E/ActivityManager(1565):    at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:3518)
02-10 19:39:03.640: E/ActivityManager(1565):    at com.android.server.am.ActivityStack.startActivityMayWait(ActivityStack.java:4213)
02-10 19:39:03.640: E/ActivityManager(1565):    at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:2696)
02-10 19:39:03.640: E/ActivityManager(1565):    at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:150)
02-10 19:39:03.640: E/ActivityManager(1565):    at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1754)
02-10 19:39:03.640: E/ActivityManager(1565):    at android.os.Binder.execTransact(Binder.java:367)
02-10 19:39:03.640: E/ActivityManager(1565):    at dalvik.system.NativeStart.run(Native Method)
02-10 19:39:03.660: E/JavaBinder(1565): *** Uncaught remote exception!  (Exceptions are not yet supported across processes.)
02-10 19:39:03.660: E/JavaBinder(1565): java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
02-10 19:39:03.660: E/JavaBinder(1565):     at java.util.ArrayList.get(ArrayList.java:306)
02-10 19:39:03.660: E/JavaBinder(1565):     at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:3518)
02-10 19:39:03.660: E/JavaBinder(1565):     at com.android.server.am.ActivityStack.startActivityMayWait(ActivityStack.java:4213)
02-10 19:39:03.660: E/JavaBinder(1565):     at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:2696)
02-10 19:39:03.660: E/JavaBinder(1565):     at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:150)
02-10 19:39:03.660: E/JavaBinder(1565):     at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1754)
02-10 19:39:03.660: E/JavaBinder(1565):     at android.os.Binder.execTransact(Binder.java:367)
02-10 19:39:03.660: E/JavaBinder(1565):     at dalvik.system.NativeStart.run(Native Method)

说实话,我不知道此错误是否与我的应用程序直接相关,但是当我尝试单击菜单或启动活动的其他元素时,该错误会显示.

To be honest, I don't know if this error is directly connected with my app, but it shows up when I try to click in my menu, or in some other element that will start the activity.

这是一些代码.正如我所说的,这只是一个小片段,但在其他设备和仿真器中都可以完美地工作.

Here is some code. This is just a little fragment but this works perfectly in the other devices and also in the emulator, as I said.

menuLogin.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        if (isAuthenticated()) {
            // some code...
        } else {
            Intent i = new Intent(BaseActivity.this,
                    AccountActivity.class);
            startActivity(i);
            overridePendingTransition(R.anim.slide_in_right,
                    R.anim.slide_out_left);
        }
    }
});

我该如何解决?

推荐答案

这里的行为很奇怪,但是显然您收到的异常似乎是在一个进程(活动1)中抛出的,但在那里没有处理.这将导致Java活页夹引发未捕获的远程异常,并使活动管理器在活动2开始时崩溃.我的建议是调试并逐步执行所有过程,直到找到导致起源异常的原因并进行处理.您可以尝试的另一件事是查看@NKN的链接或该通过数个方式抛出异常处理,看看是否有任何答案.祝你好运,调试愉快!

Very strange behaviour here, but obviously you are getting an exception that seems to be thrown in one process(activity 1) but not handled there. This leads to java binder raising the uncaught remote exception, and making the activity manager crash upon start of activity 2. My suggestion to you is to debug and step it all through until you find the cause to the origin exception and handle it. The other thing you could try is to take a look at @NKN's link or this one Throw exceptions through several processes and see if you get any answers. Good luck and happy debuggin!

这篇关于startActivity(intent)在某些设备中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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