У меня есть активность Android, которая также отображает уведомление на панели уведомлений и дальнейшее описание этого в выпадающем меню. Проблема возникает при попытке нажать на уведомление. Из того, что я видел в большинстве других проблем, установка флажка для очистки других представлений должна решить проблему. Однако вот код, который у меня есть:
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.stat_sys_secure;
CharSequence tickerText = "Browser Security Enabled";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = "Browser Security";
CharSequence contentText = "Security Vulnerability Detected";
Intent notificationIntent = new Intent(this, PrivacyMessage.class);
//Should clear current view, and show this new activity
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
final int HELLO_ID = 1;
mNotificationManager.notify(HELLO_ID, notification);
Запускаемое действие PrivacyMessage имеет созданное собственное XML-файл для содержимого и должно отображаться. Однако, когда на уведомление нажимают, оно ничего не делает, просто возвращает вас к действию, в котором вы были. Я думал, что мне может понадобиться добавить новое действие в манифест, но у меня возникли проблемы с определением, что именно я должен добавить , и где. Это текущий манифест, который у меня есть:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.browser"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:debuggable="true">
<activity android:name=".Browser"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
</manifest>
Я надеюсь, что я где-то упускаю слепо очевидное. Но есть идеи, где?