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 9198937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:24:25+00:00 2026-06-17T22:24:25+00:00

This code creates a notification. If you click it, the current application is ran

  • 0

This code creates a notification. If you click it, the current application is ran (the intent is created in Entry, which is my only Activity), a slightly modified version of a Android Developers blog:

private void makeIntent() {
    NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    Notification note = new Notification(R.drawable.prev, "Status message!", System.currentTimeMillis());
    Intent intent = new Intent(this, Entry.class);
    PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);
    note.setLatestEventInfo(this, "New Email", "Unread Conversation", pi);
    note.flags |= Notification.FLAG_AUTO_CANCEL;
    mgr.notify(NOTIFY_ME_ID, note);
}

But I don’t want to start any activity, but merely to run a method in the current activity. From what I’ve read so far, I guess I have to use methods like startActivityForResult(), use intent-filters and implement onActivityResult(), but after messing around with all those things, changing things in the Intent and PendingIntent, I still have no usable result. Is it possible to somehow just call a method in Entry (my main Activity, in which the Intent is created), or catch any outgoing or incoming Intents when I click my newly made Notification?

PS. my apologies if this is a duplicate thread, SO is quite slow right now, I can’t search properly.

  • 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-06-17T22:24:27+00:00Added an answer on June 17, 2026 at 10:24 pm

    Add android:launchMode="singleTop" in your activity in your manifest file, have the method protected void onNewIntent(Intent intent) { ... } and use this code:

    private static final int MY_NOTIFICATION_ID = 1;
    private NotificationManager notificationManager;
    private Notification myNotification;
    
    void notification() {   
        notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        myNotification = new Notification(R.drawable.next, "Notification!", System.currentTimeMillis());
        Context context = getApplicationContext();
        String notificationTitle = "Exercise of Notification!";
        String notificationText = "http://android-er.blogspot.com/";
        Intent myIntent = new Intent(this, YourActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(YourActivity.this, 0, myIntent, Intent.FILL_IN_ACTION);
        myNotification.flags |= Notification.FLAG_AUTO_CANCEL;
        myNotification.setLatestEventInfo(context, notificationTitle, notificationText, pendingIntent);
        notificationManager.notify(MY_NOTIFICATION_ID, myNotification);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code, which creates an image, and then adds some effects to
I am creating a custom code generator using c#... this generator now only creates
The service creates a persistent Notification and starts the main activity on click via
Well ive got this code that creates a table from JSON data. If a
Hi I have been working on this code that creates a table with radio
I have this JavaScript code that creates a table, and puts in the rows
How can I write this code more cleanly/concisely? /// <summary> /// Creates a set
I have this function in a Code Igniter model that creates a new video.
I have a program that creates a notification if the application is not running.
I have an application that creates a notification with sound when a specific text

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.