gpt4 book ai didi

android - AppWidgetHost 崩溃 android.os.TransactionTooLargeException

转载 作者:太空狗 更新时间:2023-10-29 14:14:45 24 4
gpt4 key购买 nike

我正在开发自定义 android 启动器。添加一些小部件(三星图库、收藏直拨)后,每次重新启动应用程序时都会崩溃。这是代码:

public static final int APPWIDGET_HOST_ID = 128;

public final class Launcher extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAppWidgetManager = AppWidgetManager.getInstance(this);
mAppWidgetHost = new AppWidgetHost(this, APPWIDGET_HOST_ID);
mAppWidgetHost.startListening(); //Here it crash
...
}
}

这是错误日志:

    java.lang.RuntimeException: Unable to start activity ComponentInfo{custom.launcherpro/custom.launcher.launcher.Launcher}: java.lang.RuntimeException: system server dead?
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
at android.app.ActivityThread.access$900(ActivityThread.java:161)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5356)
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)
Caused by: java.lang.RuntimeException: system server dead?
at android.appwidget.AppWidgetHost.startListening(AppWidgetHost.java:166)
at custom.launcher.launcher.Launcher.onCreate(Launcher.java:181)
at android.app.Activity.performCreate(Activity.java:5426)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
... 11 more
Caused by: android.os.TransactionTooLargeException
at android.os.BinderProxy.transact(Native Method)
at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.startListening(IAppWidgetService.java:465)
at android.appwidget.AppWidgetHost.startListening(AppWidgetHost.java:162)

这发生在 android 4.4 上(但甚至在旧的 android 版本上)这是什么意思?我该如何预防?

谢谢,文森佐

最佳答案

参见 TransactionTooLargeException在文档中。如果您查看 AppWidgetHost 的源代码,您会发现跟踪中提到了这段代码:

ArrayList<RemoteViews> updatedViews = new ArrayList<RemoteViews>();
// ....
updatedIds = sService.startListening(mCallbacks, mPackageName, mHostId, updatedViews);

在这种情况下,updatedViews 是一个 RemoteViews 数组。如果它们包含大量图像,它们可能会非常大。你有一些带有巨大图像的小部件吗?

关于android - AppWidgetHost 崩溃 android.os.TransactionTooLargeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23418357/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com