java - android javabinder 失败的 Binder 事务

标签 java android

尝试获得我的第一个 Android 小部件,让我告诉您从 Visual Studio Pro 迁移到 eclipse 并不是一件顺利的事情! 无论如何,我遇到了上述错误,这给我解决了一些麻烦。我已经搜索了所有可能的重复项,似乎当应用程序达到 IPC 大小(即大图像)时会发生此错误

我的小部件启动了一个 Intent 服务来从网络下载一些信息和一张图像。 png的原始图像大小约为100k。然而,在我更新小部件之前,我将尺寸缩小到 17k 左右。 (检查内存跟踪器大小为 16400bytes[])。 但更新失败。如果我删除图像,则更新成功。

这是 widgetprovider 中执行的监听器:

public void onHttpLoaded(Bitmap image, String titlestring, String subtitlestring)
    {
        Context context = getApplicationContext();          

        if (image == null) //no data?
        {
            Toast.makeText(context, context.getResources().getString(R.string.null_data_toast), Toast.LENGTH_LONG);
            return;// exit!
        }

        try
        {
            RemoteViews widgetView = new RemoteViews(this.getPackageName(), R.layout.main);             
            widgetView.setTextViewText(R.id.title, titlestring);

            //all other comment out

            //The problem!
            widgetView.setImageViewBitmap(R.id.main_icon, image);

            //Get global  appwidgetmanager
            AppWidgetManager manager = AppWidgetManager.getInstance(this);

            //update widget
            manager.updateAppWidget(Constants.THIS_APPWIDGET, widgetView);
        }
        catch (Exception e)
        {
            Log.d("onHttpLoaded", e.toString());
        }

    }

以及我的服务中的 onHandleIntent,上面的代码被调用:

protected void onHandleIntent(Intent intent)
    {
        resources = getApplicationContext().getResources();
        int iAppWidgetId;           
        try
        {
            iAppWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
        }
        catch (Exception e)
        {
            Log.d("Service", "WidgetID not found");
        }
        //comment out stuff...

        //launch new httpTask 
        httpTask myhttpTask = new httpTask(tittlestring, subtitlestring, (myHttpListener) MyUpdateService.this, MyUpdateService.this);
        //limit size of bitmap
        myhttpTask.setSampleSize(Constants.BITMAP_SAMPLE_SIZE); //size = 4
        myhttpTask.execute();

    }

所有测试均在模拟器中完成。 一个可能很重要的细节是,在 logcat 中我收到 20-30 条失败消息“!!!失败的 Binder 事务!!!” 关于我如何搞砸这件事有什么想法吗? 谢谢!

最佳答案

解决了。这是模拟器的内存问题。

关于java - android javabinder 失败的 Binder 事务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10161174/

相关文章:

java - 如果将 Spring 5.X 的 DefaultCookieSerializer 与 Tomcat 8 一起使用,如何防止创建 JSESSIONID

Java基本编译错误

java - 如何获取当前的 GPS 位置?

java - Spring框架是建立在什么基础上的

android - 如何更改 AOSP 中的默认音量级别?

java - 使用 Jsoup 解析 Html 内容

android - Android 上的 Admob - 恢复 Activity 时未覆盖状态栏区域

java - 如何使用在 PC 上运行的 java 代码启动 Android 手机相机?

Android:android 可搜索与自定义搜索 Activity

android - 将 webview 嵌入到另一个 View 中