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

  • Home
  • SEARCH
  • 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 8208187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:15:17+00:00 2026-06-07T09:15:17+00:00

I have code, and it just does not work, so I ask anyone to

  • 0

I have code, and it just does not work, so I ask anyone to help me out. There is very little info on this specific matter.

MainActivity


public class MainActivity extends Activity {
public final int PENDING_INTENT_ID = 8;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button clickity = (Button)findViewById(R.id.alarm_button);
    clickity.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar now = Calendar.getInstance();
            now.add(Calendar.SECOND, 20);

            //Create a new PendingIntent used by the Alarm when it activates
            Intent intent = new Intent(v.getContext(), AlarmReciever.class);
            intent.setAction("SOME_AWESOME_TRIGGER_WORD");
            intent.putExtra("info", "This String shows that the info is actually sent correctly");
            PendingIntent pendingIntent = PendingIntent.getBroadcast(v.getContext(), PENDING_INTENT_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT|Intent.FILL_IN_DATA);

            //Then Create the alarm manager to send this pending intent and set the date to go off
            AlarmManager am = (AlarmManager)getSystemService(Activity.ALARM_SERVICE);
            am.set(AlarmManager.RTC_WAKEUP, now.getTimeInMillis(), pendingIntent);

        }
    });

}

AlarmReciever (Aware I spelled it wrong but since thats how it is, im going with it)


public class AlarmReciever extends BroadcastReceiver{

@Override
public void onReceive(Context c, Intent arg1) {

    //get a reference to NotificationManager
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) c.getSystemService(ns);

    //Instantiate the notification

    CharSequence tickerText = "Hello";
    long when = System.currentTimeMillis();
    Notification.Builder builder = new Notification.Builder(c)
                                .setTicker(tickerText)
                                .setWhen(when)
                                .setContentTitle(arg1.getStringExtra("info"))
                                .setContentText("Success!!")
                                .setAutoCancel(true);
    Notification notification = builder.getNotification();
    mNotificationManager.notify(0, notification);//note the first argument, the ID should be unique



}
}

Manifest


<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <receiver 
        android:name="com.testproject.AlarmReciever"
        android:enabled="true"
        android:exported="false" >
        <intent-filter>
    </receiver>

</application>


That should be everything. I am trying to run it as is and its not showing me anything. I am running it on an emulator is that actually matters.

EDIT: When I say it doesn’t work, I mean nothing pops up. It runs fine, but the Notification never pops up.

The issue:
enter image description here

So the issue is narrowed down to Android just ignoring my Notification. Problem is it doesn’t tell me why -_- so I can’t fix it. Any experts on the matter see something wrong with my code to call a notification? Does it matter that its on an emulator?

  • 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-07T09:15:19+00:00Added an answer on June 7, 2026 at 9:15 am
    Intent intent = new Intent(v.getContext(), AlarmReciever.class);
    // intent.setAction("SOME_AWESOME_TRIGGER_WORD"); replace to:
    intent.setAction("com.testproject.SOME_AWESOME_TRIGGER_WORD");
    

    It’s at least for first look

    UPD:

    long firstTime = SystemClock.elapsedRealtime();
    
    AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
    alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime, /* INTERVAL IN MS */ 20 * 1000, /* PendingIntent */ intent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this test code that just saves an XML file to a folder.
I have this code in PHP writing views to a text-file and just increasing
I have this code that asks for a username and password. Just a simple
I'm implementing several classes which does not have data by itself, just logics. These
Does anyone know of a good code obsfucator for Perl? I'm being ask to
There is a question very similar to this but I wanted to ask it
I have code blindness, it's like snowblindness, just wth far too much code. I
I have some code I am working on that worked just fine until I
I have the code block below, I deleted all unnecessary parts, just left the
I just started using php arrays (and php in general) I have a code

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.