RemoteViewAdapter方法​​返回NULL错误? [英] RemoteViewAdapter method returning NULL error?

查看:167
本文介绍了RemoteViewAdapter方法​​返回NULL错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我跑这个方法对我的StackView ...

Whenever i run this method for my StackView...

@Override
public RemoteViews getViewAt(int position) {

    RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);


    Bundle extras = new Bundle();
    extras.putInt(stackWidgetProvider.EXTRA_ITEM, position);
    Intent fillnIntent = new Intent();
    fillnIntent.putExtras(extras);
    rv.setOnClickFillInIntent(R.id.widget_item, fillnIntent);
    rv.setImageViewBitmap(R.id.wigdetView, bm);
    MyTask myTask = new MyTask();
    myTask.execute();


    //Do heavy lifting here, Downloading images from a network or website.

    return rv ;
}

我得到这个错误在调试..

I get this error in the debug..

08-01 19:48:00.520: ERROR/RemoteViewsAdapter(14319): Error in updateRemoteViews(24): null
08-01 19:48:05.530: ERROR/AppWidgetService(131): Error (unbindRemoteViewsService): Connection not bound

下面是我的updateRemoteiews()在这里...

Here is my updateRemoteiews() here...

public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

    for(int i = 0; i < appWidgetIds.length; ++i) {

        Intent intent = new Intent(context, StackWidgetService.class);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);

        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);

        rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);

        rv.setEmptyView(R.id.stack_view, R.id.add);

        Intent toastIntent = new Intent(context, stackWidgetProvider.class);
        toastIntent.setAction(stackWidgetProvider.TOAST_ACTION);
        toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);

        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);

        appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
    }

还有什么问题是??

What could the problem be??

推荐答案

我只是有这个同样的问题,我的问题是,我是装的图像是太大了。注释掉code的图像后,我的问题就走了,所以现在我必须寻找为一种解决方法(我正在寻找在的 https://groups.google.com/forum/#​​!topic/android-developers/bp8ddUGHGhE )。

I just had this same issue and my problem was that the images that I was loading were too big. After commenting out the code for the images, my problem went away, so now I have to look for a workaround for that (I'm looking for a solution at https://groups.google.com/forum/#!topic/android-developers/bp8ddUGHGhE).

此错误也伴随着在日志猫失败粘合剂交​​易。

This error is also accompanied by a "FAILED Binder Transaction" in the log cat.

这篇关于RemoteViewAdapter方法​​返回NULL错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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