开发者

android getAppWidgetIds failed, what wrong?

开发者 https://www.devze.com 2022-12-23 23:39 出处:网络
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?

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

精彩评论

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