2011-12-21 2 views
0

通知バーの画像をクリックした後で、そのアクティビティをどのように意図することができますか? 私はどのように意思を表明できますか?おかげさまで Android通知を押したときのアクティビティの意思決定方法

public class AlarmService extends BroadcastReceiver { 
NotificationManager nm; 

@Override 
public void onReceive(Context context, Intent intent) { 
    nm = (NotificationManager) context 
      .getSystemService(Context.NOTIFICATION_SERVICE); 
    CharSequence from = "Check your fridge"; 
    CharSequence message = "It's time to eat!"; 
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, 
      new Intent(), 0); 
    Notification notif = new Notification(R.drawable.fridge_icon3, 
      "Keep Fridge", System.currentTimeMillis()); 
    notif.setLatestEventInfo(context, from, message, contentIntent); 
    notif.defaults |= Notification.DEFAULT_SOUND; 
    notif.flags |= Notification.FLAG_AUTO_CANCEL; 
    nm.notify(1, notif); 
} 
} 

答えて

1

あなたが投稿したコードには、既に意図があります。あなたはcontentIntentに新しいIntent()を持っています。あなたが何かでそれを埋めていないのであまり役に立ちません。あなたはこのようなものが必要です。 here

+1

Intent notificationIntent = new Intent(this, MyAvtivity.class); // modify the intent as nessasary here. PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); 

ユーザーガイドがご案内いただき、ありがとうございます。私はこの\t \t PendingIntent contentIntent = PendingIntent.getActivity(文脈、0、 \t \t \t \t新しいテント(文脈、KeepFridgeActivity.class)、0)のように置きます。とりあえずありがとう! – wholee1

+0

同じ問題が私に起こり、あなたのソリューションはうまくいきました。:-)乾杯! – YuDroid

関連する問題