android getAppWidgetIds failed, what wrong?

Posted by bright on Stack Overflow See other posts from Stack Overflow or by bright
Published on 2010-03-19T02:24:17Z Indexed on 2010/03/19 2:31 UTC
Read the original article Hit count: 480

Filed under:

I want to use following code to get a widget id, but getAppWidgetIds always return an empty array, the num is alway 0, what wrong?

Thanks!

public class test extends Activity implements  OnTouchListener {
    public void onCreate(Bundle savedInstanceState) {
        super.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;

© Stack Overflow or respective owner

Related posts about android