1、在 OnUpdate()中 定义一个 Intent Intent startActivityIntent = new Intent(context,WidgetLife.class); 2、实例化一个 PendingIntent PendingIntent Pintent = PendingIntent.getActivity(context,0,startActivityIntent,0); 3、实例RemoteView RemoteViews ActivityView = new RemoteViews(context.getPackageName(),R.layout.widget_layout); 4、Button 事件 ActivityView.setOnClickPendingIntent(R.id.Button,Pintent); 5、更新Widget appWidgetManager.updateAppWidget(appWidgetIds,ActivityView); |