开发者

android getAppWidgetIds failed, what wrong?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜