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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:48:04+00:00 2026-06-16T02:48:04+00:00

I created an app that after boot completed starts an intent, an alarmamanager and

  • 0

I created an app that after boot completed starts an intent, an alarmamanager and next a notification bar. After reboot, Notify class runs, but at fixed time I didn’t see notification on bar.

Another question: Can I starts notification bar from Notify class without call AlarmReceiver class?

AutoStart

public class AutoStart extends BroadcastReceiver{

@Override
public void onReceive(Context context, Intent intent) {
        Intent i = new Intent(context, Notify.class);  
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(i);  
}

Notify

public class Notify extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

Calendar cal1 = Calendar.getInstance();
cal1.set(Calendar.HOUR_OF_DAY, 05);
cal1.set(Calendar.MINUTE, 45);
cal1.set(Calendar.SECOND, 00);

Calendar cal2 = Calendar.getInstance();
cal2.set(Calendar.HOUR_OF_DAY, 17);
cal2.set(Calendar.MINUTE, 30);
cal2.set(Calendar.SECOND, 00);

Calendar now = Calendar.getInstance();
if(now.after(cal1))
    cal1.add(Calendar.HOUR_OF_DAY, 24);
if(now.after(cal2))
    cal2.add(Calendar.HOUR_OF_DAY, 24);

Intent intent = new Intent(this, AlarmReceiver.class);
PendingIntent morningAlarm = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0);
PendingIntent eveningAlarm = PendingIntent.getBroadcast(getApplicationContext(), 1, intent, 0);

AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, cal1.getTimeInMillis(), DateUtils.DAY_IN_MILLIS, morningAlarm);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, cal2.getTimeInMillis(), DateUtils.DAY_IN_MILLIS, eveningAlarm);

AlarmReceiver:

public class AlarmReceiver extends BroadcastReceiver {

    final String not1[] = new String[37];
    int not1end = 36;
    int x;

    public void onReceive(Context context, Intent intent) {

not1[0]="one";
        not1[1]="two";
        not1[2]="three";


     String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);

        int icon = R.drawable.ic_launcher;
        CharSequence tickerText = "Votre vidange approche";
        long when = System.currentTimeMillis();

        Notification notification = new Notification(icon, tickerText, when);


        CharSequence contentTitle = "Notification";
        CharSequence contentText = "Vérifier votre kilométrage";
        Intent notificationIntent = new Intent("org.gortcloud.perledisaggezza");
//        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

        final int HELLO_ID = 1;

        mNotificationManager.notify(HELLO_ID, notification);
     }     

Manifest

<receiver 
    android:name=".Notify"
    android:exported="false" >
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>

<receiver android:name="AlarmReceiver" >
            <intent-filter>
                <action android:name="com.example.AlarmReceiver" />
            </intent-filter>

<intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>
  • 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-16T02:48:05+00:00Added an answer on June 16, 2026 at 2:48 am

    In AlarmReceiver.onReceive() you create the Notification object but you never queue it. You need to call NotificationManager.notify() like this:

    mNotificationManager.notify(MY_NOTIFICATION_ID, notification);
    

    where MY_NOTIFICATION_ID is any integer value. Later, if you need to cancel the notification you will use this value like this:

    mNotificationManager.cancel(MY_NOTIFICATION_ID);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After some studying, I created a small app that calculates DFTs (Discrete Fourier Transformations)
I've created a small iphone app that contains a tab bar controller that has
I have created an app that sends intents among multiple activities. After doing some
I created an app that acts as a launcher, which works as expected, but
I've created an app that contains 4 viewcontroller and its .h,.m files...In my firstviewcontroller
I've created an app that shows 8 buttons in coverflow using icarousel.i have to
I have successfully created an app that reads from a bundled .plist file and
I have created an app that uses NSTimer, which gets triggered each second. My
I debug with a Samsung Galaxy SII, running 2.3.6. I created an app that
I created a console app that I want to use in a scheduled package

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.