1

I have a service with a foreground notification. How can launch an activity when user tap on the foreground Notification?

I have tried with:

// CREATE NOTIFICATION FOREGROUND
    Intent notificationIntent = new Intent(getApplicationContext(), HomeActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);
    Notification notification = new NotificationCompat.Builder(getApplicationContext())
            .setContentTitle("Title")
            .setTicker("Test service")
            .setContentIntent(contentIntent)
            .setContentText("text...").build();
    startForeground(1, notification);
    //======================================================================================

i need to start HomeActivity when user tap foreground notification.

user2543127
  • 385
  • 10
  • 21
  • What specific problems did you run into with the code that you have? – CommonsWare May 29 '15 at 20:31
  • When tap on foreground Notification, Android show me a page about application info (for quit app, or see memory detalis). – user2543127 May 30 '15 at 17:47
  • 2
    I managed to solve it by using notificationBuilder.setSmallIcon. Its neccessary to set that property for notification to appear. See this thread: http://stackoverflow.com/questions/23148734/androidstart-foreground-wont-display-notification-properly – vamyip Jan 16 '16 at 11:21

0 Answers0