2012-10-18 53 views
0

我表現的,一旦放置在主屏幕上一個小部件啓動一個活動的Widget不留

,所以我必須:

public class WidgetActivity extends AppWidgetProvider 
{  
    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgets) { 
     RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_activity); 
     Intent intent = new Intent(context, Info.class); 
     PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); 
     remoteViews.setOnClickPendingIntent(R.id.Widget, pendingIntent); 
    } 
} 

而且

public class Info extends Activity { 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.widget_activity_info); 
    } 
} 

但之後成功推出widget_activity_info .xml小部件在按下回家或回家後不在主屏幕上。我在這裏錯過了什麼嗎?在我啓動新活動之前,小部件將保留在屏幕上。

回答