I want to open an Activity when I click on the notification from the Status bar. I have seen this answered on StackOverflow but none of these answers work for me. This is my code:
notificationBuilder = new NotificationCompat.Builder(this); notificationBuilder.setProgress(100, 0, false); notificationBuilder.setAutoCancel(true); notificationBuilder.setSmallIcon(R.drawable.ic_action_file_cloud_upload); notificationBuilder.setContentTitle(getString(R.string.notification_upload_title)); //when this notification is clicked and the upload is running, open the upload fragment Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK); // set intent so it does not start a new activity PendingIntent intent = PendingIntent.getActivity(this, 1, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT); notificationBuilder.setContentIntent(intent); this.startForeground(NOTIFICATION_ID_UPLOADING_PROGRESS, notificationBuilder.build()); Manifest.xml
<activity android:name="com.android.app.MainActivity_" android:label="@string/app_short_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
this.startForegroundinstead ofNotificationManager.notify?