【发布时间】:2014-05-23 17:24:23
【问题描述】:
我的问题是,如果我点击通知,它会关闭但不会打开活动 垂直计划。有什么问题?
这是我的代码:
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
int auswertungsergebnis = 0;
boolean weekday = checkDay();
if (weekday == true) {
auswertungsergebnis = auswerten();
}
String ausgabe = ausfaller.toString().replace("[", "").replace("]", "");
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ACTION);
registerReceiver(notifyServiceReceiver, intentFilter);
// Send Notification
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
myNotification = new Notification(R.drawable.ic_stat_gymi,
"Notification!", System.currentTimeMillis());
Context context = getApplicationContext();
String notificationTitle = "Neue Vertretungsstunden!";
String notificationText = ausgabe + " fällt heute aus";
Intent myIntent = new Intent(context, Vertretungsplan.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
getBaseContext(), 0, myIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
myNotification.defaults |= Notification.DEFAULT_SOUND;
myNotification.flags |= Notification.FLAG_AUTO_CANCEL;
myNotification.setLatestEventInfo(context, notificationTitle,
notificationText, pendingIntent);
if (auswertungsergebnis == 1) {
notificationManager.notify(MY_NOTIFICATION_ID, myNotification);
}
return super.onStartCommand(intent, flags, startId);
}
提前谢谢你:)
【问题讨论】:
标签: android android-intent service notifications