我已经有一个适用于 Android 的状态栏通知,但要创建它,我必须设置一个 Activity 才能打开它。我不想打开任何活动;但是,这个小项目根本不需要接口。
mNotificationManager = (NotificationManager) aContext
.getApplicationContext().getSystemService(
Context.NOTIFICATION_SERVICE);
// Create the pending intent, which is basically NOW.
PendingIntent contentIntent = PendingIntent
.getActivity(aContext, 1, new Intent(aContext, BlankActivity.class),
PendingIntent.FLAG_CANCEL_CURRENT);
// Create notification
notificationBuilder = new NotificationCompat.Builder(aContext)
.setContentIntent(contentIntent)
.setSmallIcon(R.drawable.ic_launcher) // required for launch
.setTicker("Downloading video...") // required for launch
.setWhen(System.currentTimeMillis()) // should be set for now.
.setContent(remoteView);
BlankActivity
听起来就是这样——一个没有内容并在打开时关闭的活动。但它仍然显示在最近打开的窗口列表中。我无法将其设置为 null。
有没有办法完全避免为状态通知设置意图?