I want to use following code to get a widget id, but getAppWidgetIds always return an empty array, the num is always 0, what wrong?
Thanks!
public class test extends Activity implements OnTouchListener {
public void onCreate(Bundle savedInstanceState) {
super开发者_Python百科.onCreate(savedInstanceState);
.....
AppWidgetManager mAppWidgetManager;
AppWidgetHost mAppWidgetHost;
mAppWidgetManager = AppWidgetManager.getInstance(this.getApplicationContext());
ComponentName THIS_APPWIDGET =new ComponentName("com.android.music", "com.android.music.MediaAppWidgetProvider");
int[] appWidgetId=mAppWidgetManager.getAppWidgetIds(THIS_APPWIDGET);
int num=appWidgetId.length;
Use
new ComponentName(context, com.android.music.MediaAppWidgetProvider.class)
instead.
精彩评论