数组长度错误,通知管理器导致4.4的电话崩溃 [英] bad array lengths, notification manager causes phone crash on 4.4

查看:117
本文介绍了数组长度错误,通知管理器导致4.4的电话崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我启动了该应用程序的Beta测试,有4.4个设备的多个用户报告该应用程序导致整个手机崩溃,即使该应用程序甚至没有此权限,该手机在应用程序启动后也几乎会重启.

I launched app into BETA testing and multiple users with 4.4 Devices reported that the app causes whole phone to crash, phone pretty much restarts after app launch even though app doesn't even have such permissions.

我从测试人员那里得到的报告如下:

The report I got from testers is as follows:

java.lang.RuntimeException: bad array lengths
at android.os.Parcel.readIntArray(Parcel.java:820)
at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:348)
at android.app.NotificationManager.notify(NotificationManager.java:139)
at android.app.NotificationManager.notify(NotificationManager.java:112)
at als.wakeup.Awake_Alarm$MyLocationListener.onLocationChanged(Awake_Alarm.java:272)
at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:279)
at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:208)
at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:224)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)

这在4.2、4.3上正常工作,但似乎运行4.4的Galaxy Note 3和Galaxy S5重新启动.

This works fine on 4.2, 4.3 but it seems that Galaxy Note 3 and Galaxy S5 which run 4.4 restart.

原因可能是什么?是与应用相关的还是在新操作系统中出现故障?

What could the cause be? Is it app related or could it be glitch in new OS?

只是发现它在Xperia Z1 4.4上可以正常工作且没有崩溃.似乎只有三星会引起这种情况,有什么提示吗?

Just found out it works fine on Xperia Z1 with 4.4 and no crashes. It seems that only samsung causes this, any tips?

通知创建功能:

public Notification CreateNotification(double distance){


    Intent notificationIntentStop = new Intent(this.getApplicationContext(), StopService.class);
    PendingIntent contentIntentStop = PendingIntent.getActivity(this.getApplicationContext(), 0, notificationIntentStop, 0);


    Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.logo);
    Shortcuts shorts = new Shortcuts(this);
    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.logo)
            .setContentTitle("Localarm Running")
            .setLargeIcon(largeIcon);
    //mBuilder.addAction(R.drawable.ico, "Stop", contentIntentStop);
    if(distance > 0){
    mBuilder.setContentText(String.valueOf(roundTwoDecimals(shorts.ConvertUnits(distance))+" "+shorts.GetUnitNames(distance)+" to Alarm."));
    }
    else{
    mBuilder.setContentText(String.valueOf("You've reached your destination"));
    }
    mBuilder.setPriority(Notification.PRIORITY_MAX);
    Notification bui = mBuilder.build();

    bui.flags|= Notification.FLAG_NO_CLEAR;
        Intent notificationIntent = new Intent(this.getApplicationContext(), Intro.class);
        PendingIntent contentIntent = PendingIntent.getActivity(this.getApplicationContext(), 0, notificationIntent, 0);
        bui.contentIntent = contentIntent;



    return bui;

}

通过以下方式调用:onLocationChanged()

it gets called by: onLocationChanged()

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);        
    notificationManager.notify(0, CreateNotification(dist_difference-alert_range));

推荐答案

这是问题.不幸的是,我认为您对此无能为力.

This is an issue in Android. Unfortunately, I don't think you can do anything about it.

这篇关于数组长度错误,通知管理器导致4.4的电话崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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