2012-04-15 83 views
0

試圖讓我的第一個Android小工具,讓我告訴你,從Visual Studio Pro的日食移動是不順利的事情! 無論如何,我碰上了上面的錯誤,給了我一些麻煩來解決。我找到了所有可能的重複,看起來這個錯誤發生時,應用程序點擊IPC大小(即大圖像)安卓javabinder失敗粘結劑交易

我的小部件啓動intentservice從網絡和一個圖像下載一些信息。 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失敗的消息「!失敗粘合劑交易!!!」 我如何搞砸這件事的任何想法? thnks!

+0

解決.......... – Ray 2012-04-19 08:19:27

回答

1

解決。這是模擬器的內存問題。