Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6126441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:22:27+00:00 2026-05-23T16:22:27+00:00

I have an android activity that also displays a notification on the notification bar,

  • 0

I have an android activity that also displays a notification on the notification bar, and a further description of it in the pulldown menu. The problem happens when trying to click the notification. From what I have seen in most other problems, putting a flag on it to clear other views should fix the problem. However this is the code I have:

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);

The activity that it launches, PrivacyMessage has an oncreate that sets its own XML file to be the contentview, and should be showing up. However, when the notification is clicked, it does nothing, just returns you to the activity you were in. My thinking was that I might need to add the new activity into the manifest, but was having trouble figuring out exactly what I should be adding, and where. This is the current manifest that I have:

<?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>

I’m hoping that I’m just missing the blindingly obvious somewhere. But any ideas where?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:22:28+00:00Added an answer on May 23, 2026 at 4:22 pm

    First of all the flags don’t force the creation of a new activity if at least one is available, so in most cases only the onResume method will be called (check the Activity lifecycle).

    Then, if you have a single activity, how does it know what to display ? What you need to do is have a way to differentiate the intents between calling the app from a launcher, and calling it from a notification.

    You should create a second intent filter in your manifest specifically for the notification handling. Then in your onCreate / onResume, check the intent to know in which case you are and populate your view accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a very simple android activity that starts a timer when you
So what I am trying to create is an activity that displays an image
Im trying to implement an activity that uses ExpandableListView and I have gotten so
While extending a sample Android activity that fires some other activities from its menu,
I have an Android application that contains two Activities . Activity A has a
I have created an application for Android that has an activity that has a
I have an Activity in Android, with two elements: EditText ListView When my Activity
I have Activity A with android:launchMode=singleTop in the manifest. If I go to Activity
I have android.permission.READ_OWNER_DATA but I can't find any reliable code that would explain how
I have a android webservice client application. I am trying to use the java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.