Challange Solution 2 the harder


i done this challange by put new method in

private void createNotif(){ NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getActivity()) .setSmallIcon(android.R.drawable.ic_menu_report_image) .setContentTitle("My notification") .setContentText("Hello World!"); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(getActivity(), RunActivity.class); //Bundle args = getArguments(); resultIntent.putExtra(RunActivity.EXTRA_RUN_ID, mRun.getId()); TaskStackBuilder stackBuilder = TaskStackBuilder.create(getActivity()); stackBuilder.addParentStack(RunListActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(0,; }

and call this method in startButton

[code]mStartButton.setOnClickListener(new View.OnClickListener() {

		public void onClick(View v) {
			if (mRun == null) {
				mRun = mRunManager.startNewRun();
			} else {

I follow google ApiGuides ini here

thanks, all have a nice day


I pretty much did the same as previous post from andreya following google ApiGuides.

However, there is an issue which I cannot resolve and that is when clicking the notification, this takes you to the running activity but when I press the back button or the “Up” button on the ActionBar it closes the application. The expected behaviour should be to go back to RunListActivity, it appears that the stackbuilder fails to open RunListActivity.

The code I have written is correct and everything in the manifest is also where it should be. In fact, if in resultIntent you use RunListActivity.class instead of RunActivity.class it will launch two instances/windows of RunListActivity.class as expected which means the code is correct, but for some reason RunActivity.class doesn’t behave this way.

If someone has an explanation or has done this challenge with it working as I describe above please post and let us know! :slight_smile: