PlaceSearch.java
ウィジェットの Configure クラスでもあるアクティビティがあります。私は天気ウィジェットを開発しているので、とFrameLayout
で構成されるものを使用しています。こちらのリンクをご覧ください。ImageButton
LinearLayout
PlaceSearch.java
ユーザーが をクリックしたときwidget
に開きたいhome screen
。だから私はそれを実装するために次のコードを使用しました
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
// TODO Auto-generated method stub
super.onUpdate(context, appWidgetManager, appWidgetIds);
System.out.println("entering onUpdate");
context.startService(new Intent(context, TimeService.class));
for(int id: appWidgetIds){
System.out.println(id);
RemoteViews view = new RemoteViews(context.getPackageName(),R.layout.activity_main);
Intent intent = new Intent(context,Preferences.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pi =PendingIntent.getBroadcast(context, 0, intent, 0);
view.setOnClickPendingIntent(R.id.ibmainBackground, pi);
appWidgetManager.updateAppWidget(id, view);
}
}
しかし、これはおそらくオーバーラップするFrameLayout
ため、実際にはクリックされないため、機能していません。もしそうなら、アクティビティを開く正しい方法を教えてください。LinearLayout
ImageButton
ImageButton