2011-10-28 17 views
5

私は2つのボタンでウィジェットを作成しています。 それらの1つはウィジェットのコンテンツを更新し、2つ目はウィジェットを起動する必要があります。PendingIntentsを持つ2つのボタン - ウィジェット

私はそれぞれのアクションに対して2つのPendingIntentを持っていますが、それらを両方とも動作させることはできません。一方がうまく動作しない場合、他方は動作しません。

私はコードを改訂し、何が間違っているのか理解できません。

ご協力いただきますようお願い申し上げます。

これはコードです。

RemoteViews controls = new RemoteViews(context.getPackageName(), R.layout.miwidget); 

    Intent intent = new Intent("actony.com.ACTUALIZAR_WIDGET"); 
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId); 


    Intent intentSettings = new Intent(); 
    intentSettings.setClass(context,WidgetConfig.class); 


    PendingIntent pendingIntentUpdate = PendingIntent.getBroadcast(context, widgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT); 
    controls.setOnClickPendingIntent(R.id.BtnActualizar, pendingIntentUpdate); 

    PendingIntent pendingIntentSettings = PendingIntent.getActivity(context, 0, intentSettings, 0); 
    controls.setOnClickPendingIntent(R.id.botonSettings, pendingIntentSettings); 

答えて

2

aswell getActivity PendingIntent.FLAG_UPDATE_CURRENTを追加してみてください...

PendingIntent pendingIntentSettings = 
     PendingIntent.getActivity(context, 0, intentSettings, PendingIntent.FLAG_UPDATE_CURRENT); 

と複数のウィジェットのは、あまりにもそこwidgetIdがを追加することも可能ですか。

マニフェストファイルに両方のアクティビティ/ブロードキャストがリストされていることを確認してください。

また、このコンストラクタでテントを作成してみてください。必要に応じて

Intent intent = new Intent(context,ACTUALIZAR_WIDGET.class); 
Intent intentSettings = new Intent(context,WidgetConfig.class); 

は輸入品を追加します。

ウィジェットの一部がウィジェットの仕事になると願っています。ウィジェット内の二つ以上のボタンがある場合にクリックされたボタン知る

関連する問題