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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:03:29+00:00 2026-05-27T22:03:29+00:00

I am going to create the notification and want to show it on the

  • 0

I am going to create the notification and want to show it on the onReceiver of the BroadcastReceiver. But i am not able to do it. why ?
The code for my class is:

public class AlarmNotificationReceiver extends BroadcastReceiver{
//private Intent intent;
private NotificationManager notificationManager;
private Notification notification;
@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub

    long value1 = intent.getLongExtra("param1", 0);     
    String value2 = intent.getStringExtra("param2");
    Toast.makeText(context, "Hello! How r u ?", Toast.LENGTH_SHORT).show();
    addTwoMonthNotification();  

}

private void addTwoMonthNotification(){
    notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    int icon = R.drawable.icon;
    CharSequence text = "Your amout is due on this date";
    CharSequence contentTitle = "Tax Calculator App";
    CharSequence contentText = "Your tax amount is due on the "+System.currentTimeMillis()+"";
    long when = System.currentTimeMillis();

    Intent intent = new Intent(this, NotificationViewer.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);
    notification = new Notification(icon,text,when);

    long[] vibrate = {0,100,200,300};
    notification.vibrate = vibrate;

    notification.ledARGB = Color.RED;
    notification.ledOffMS = 300;
    notification.ledOnMS = 300;

    notification.defaults |= Notification.DEFAULT_LIGHTS;
    //notification.flags |= Notification.FLAG_SHOW_LIGHTS;

    notification.setLatestEventInfo(this, contentTitle, contentText, contentIntent);
    notificationManager.notify(NotificationConstants.NOTIFICATION_ID, notification);
}

}

Give Solution for it.
Thanks.

  • 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-27T22:03:30+00:00Added an answer on May 27, 2026 at 10:03 pm

    Have you seen this:
    startActivity() from BroadcastReceiver

    It doesn’t look like you are using Context.registerReceiver() so you would have to statically add your receiver to the manifest, if you haven’t already:

    make sure you have the following in your manifest

    <receiver android:name=".AlarmNotificationReceiver">
        <intent-filter>
                <action android:name="android.intent.action.PHONE_STATE" />
        </intent-filter>
    </receiver>
    

    Above, PHONE_STATE is just an example of an intent that may be used in conjuntion with the BroadcastReceiver

    More reference: http://thinkandroid.wordpress.com/2010/02/02/custom-intents-and-broadcasting-with-receivers/

    Hope that helps!

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

Sidebar

Related Questions

We are going to create Jar Store the way like App Store works, but
I can create database manually by going to cpanel. But I'd like to create
I am am going to make a app where i want to create a
I'm going to create statistics based on information what builds were success or not
In My application i am going to use this code to use the Notification:
I'm going to create a new add-on for my n2 based website, but I
I am going to create a web site or you may call it a
I am going to create a script that sends out an email. I am
I'm going to create widget which needs to update its content every minute (it
I am going to create a typical business application that will be used by

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.