【问题标题】:android javabinder failed binder transactionandroid javabinder失败的活页夹事务
【发布时间】:2012-04-15 10:21:48
【问题描述】:

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

我的小部件启动了一个意图服务来从网络上下载一些信息和一张图片。 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 条失败消息“!!!活页夹事务失败!!!” 关于我是如何搞砸的有什么想法吗? 谢谢!

【问题讨论】:

    标签: java android


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-14
      • 2011-12-22
      • 1970-01-01
      • 2011-04-01
      • 1970-01-01
      • 2012-01-30
      • 2020-06-23
      相关资源
      最近更新 更多