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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:11:35+00:00 2026-05-27T19:11:35+00:00

I have created a service which displays a status bar notification after certain time

  • 0

I have created a service which displays a status bar notification after certain time interval.
I also have created broadcast receiver which starts the service when phone restarts or power on. The problem I am facing is that when phone restarts , I see the notification in bar, but after that the application launches. I don’t want the application to launch itself, it should only launch when user clicks on the notification.

My code for Broad Cast Receiver:

@Override
    public void onReceive(Context context, Intent intent) {



        if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {


            try
            {
                Intent intent1 = new  Intent(context, NotificationService.class);
                context.startService(intent1);

            }
            catch(Exception e)
            {

            }


        }

    }

My code for notification is :

public static void showNotification(Context context )
    {


    NotificationManager notificationManager = (NotificationManager)         context.getSystemService(Context.NOTIFICATION_SERVICE);

    Notification notification = new Notification(R.drawable.ic_launcher, "Pull Me Down!!", 1000);
    Intent intent = new Intent(context,X.class);
    PendingIntent  pendingIntent = PendingIntent.getService(context, 0, intent, 0);
    notification.setLatestEventInfo(context, "I came!!", "My First Notifcation" , pendingIntent);
    notificationManager.notify(MY_ID, notification);

    }

I am calling above method in onCreate of my Service. and also calling it in my X activity class:

NotificationService.setActivity(StatusBarNotificationActivity.this);
                startService(new Intent(getApplicationContext(), NotificationService.class));

But don’t know why when phone starts notification is show but after few seconds the X activity also launches.

  • 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-27T19:11:35+00:00Added an answer on May 27, 2026 at 7:11 pm

    Solved it, just declared the NotificationManager and Notification outside the method, and it worked.

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

Sidebar

Related Questions

I have created a web service which has a couple of methods developed using
I have created a web service which is saving some data into to db.
I am a WCF / Security Newb. I have created a WCF service which
I have created a simple wcf service which used the WCF Service Library template.
I have created a WCF service for uploading images , which accepts System.IO.Stream as
I have created an installation package using Wix which installs a Windows service on
I have created an activity in which I have created a progress bar as
I have a service which creates a number of child processes. Using c# I
I have two windows application, one is a windows service which create EventWaitHandle and
I have a web service method in which I create a particular type of

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.