我的代碼在下面有什麼問題?我希望MainActivity在觸摸/點擊通知後打開。我的代碼如下:點擊通知沒有打開活動
private void sendNotification(Quote quote) {
mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
String message = quote.getQuote() + " - " + quote.getAuthor();
// Creates an Intent for the Activity
Intent notifyIntent = new Intent(this, MainActivity.class);
notifyIntent.putExtra(Intent.EXTRA_SUBJECT, DailyQuotes.NOTIFICATION_QOD_MODE);
notifyIntent.putExtra(Intent.EXTRA_TEXT, quote.getQuoteID());
notifyIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getString(R.string.qod_title))
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(message))
.setContentText(message);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(DailyQuotes.NOTIFICATION_QOD_ID, mBuilder.build());
}
請任何人都可以幫助我解決這個問題。
試試這個'PendingIntent contentIntent = PendingIntent.getActivity(this,0,notifyIntent,0);' – 2014-12-02 11:58:04