0

PlaceSearch.javaウィジェットの Configure クラスでもあるアクティビティがあります。私は天気ウィジェットを開発しているので、とFrameLayoutで構成されるものを使用しています。こちらのリンクをご覧くださいImageButtonLinearLayout

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ため、実際にはクリックされないため、機能していません。もしそうなら、アクティビティを開く正しい方法を教えてください。LinearLayoutImageButtonImageButton

4

1 に答える 1