窗口小部件不响应 [英] Widget does not respond

查看:212
本文介绍了窗口小部件不响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的小工具,用来更新服务。它有按钮就可以打开活动。它完美。但是,有时我点击小工具打开活动,它不会工作或更新。

I have Widget that uses a service to update. It has button on it to open the activity. It works perfectly. However, sometimes i click on the widget to open the activity and it wont work or update.

我的问题是:  是什么杀死了一个应用程序窗口小部件。而如果小工具是死的,为什么它仍然显示在屏幕上。 反正是有重温特定插件,而无需创建另一回事。

My question is: what kills an app widget. And if the widget is dead, why is it still showing on the screen. Is there anyway to relive that specific widget without creating another.

感谢

推荐答案

我必须包括该code在我的服务类。它所做的基本上它发送更新,每一个部件。它已经过了一年多,我的插件的按钮总是工作,并没有任何问题的部件的更新。我张贴这种希望这会帮助别人同样的问题。我花了一年的时间解决这个问题。

I had to include this code in my service class. What it does basically it sends the update to every single widget. Its been over a year now, the button on my widget always works and the widget updates without any problem. I'm posting this hoping it will help someone with the same problem. It took me over a year to solve it.

int[] arrayOfInt = AppWidgetManager.getInstance(getBaseContext())
            .getAppWidgetIds(new ComponentName(this, mywidget.class));
    AppWidgetManager localAppWidgetManager = AppWidgetManager
            .getInstance(this);

    new WebView().onUpdate(getBaseContext(), localAppWidgetManager,
            arrayOfInt);
    int i = arrayOfInt.length;
    for (int j = 0;; j++) {
        if (j >= i)
            return;
        int k = arrayOfInt[j];
        RemoteViews localRemoteViews = new RemoteViews(getBaseContext()
                .getPackageName(), R.layout.xx);
        localRemoteViews.setTextViewText(R.id.tv, tv_text);
        localRemoteViews.setOnClickPendingIntent(R.id.Button01,
                PendingIntent.getActivity(getBaseContext(), 0, new Intent(
                        getBaseContext(), LicenseCheck.class), 1));
        localAppWidgetManager.updateAppWidget(k, localRemoteViews);
    }

这篇关于窗口小部件不响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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