【发布时间】:2015-03-10 12:41:28
【问题描述】:
我正在创建一个应用程序,目前我的要求是避免用户在主屏幕中创建多个应用程序小部件。 我是这样尝试的
@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getAction()){
case AppWidgetManager.ACTION_APPWIDGET_PICK:
Util.logD(TAG, "---APP WIDGET PICKED----");
break;
case AppWidgetManager.ACTION_APPWIDGET_DELETED:
Util.logD(TAG, "---APP WIDGET DELETED----");
break;
case AppWidgetManager.ACTION_APPWIDGET_BIND:
Util.logD(TAG, "---APP WIDGET BINDED----");
break;
case AppWidgetManager.ACTION_APPWIDGET_CONFIGURE:
Util.logD(TAG, "---APP WIDGET CONFIGURED----");
break;
case AppWidgetManager.ACTION_APPWIDGET_ENABLED:
Util.logD(TAG, "---APP WIDGET ENABLED----");
break;
case AppWidgetManager.ACTION_APPWIDGET_DISABLED:
Util.logD(TAG, "---APP WIDGET DISABLED----");
break;
case AppWidgetManager.ACTION_APPWIDGET_UPDATE:
Util.logD(TAG, "---APP WIDGET UPDATED----");
int ids[] =intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
Util.logD(TAG, "---TOTAL APP WIDGET----" + ids.length);
Util.logD(TAG, "---WIDGET VALUE----" + ids[0]);
int [] id = {ids[0]};
RemoteViews views = new RemoteViews(MainApplication.getsApplicationContext().getPackageName(), R.layout.widget_layout);
AppWidgetManager manger = (AppWidgetManager) MainApplication.getsApplicationContext().getSystemService(Context.APPWIDGET_SERVICE);
Util.logD(TAG, "---MANAGER SERVICIE----" + manger);
manger.updateAppWidget(id, views);
break;
}
}
但是控制台正在打印
--TOTAL APP WIDGET---1
--WIDGET VALUE--43
而您可以在主屏幕中找到多个应用小部件。 请帮助我,谢谢!
【问题讨论】:
-
为什么要限制用户创建多个应用小部件?..你可以处理多个应用小部件!!!
-
这是我客户的要求!请协助是否可能。
-
我觉得不可能!!!
-
有任何替代解决方案吗??
标签: android android-widget android-appwidget