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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:12:07+00:00 2026-06-07T02:12:07+00:00

I have created a method which it is called by pressing a save button

  • 0

I have created a method which it is called by pressing a save button under my main activity as follows:

public  void scheduleAlarms(Context ctxt) {
        String [] calvalue = (MessageDelay.getSelectedItem().toString()).split(" ",   3);
        int H = Integer.parseInt(calvalue[1]);
        Log.v("Timer","Timer"+H);

        switch (H){

        case 9:
                H=9;
                break;
        case 12:
                H=12;
                break;

        case 3: 
                H=15;
                break;
        case 5: 
                H=17;
                break;
        case 6: 
                H=18;
                break;
        case 8: 
                H=20;
                break;

        }
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY, H);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);

          AlarmManager mgr=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
          Intent i=new Intent(getApplicationContext(), AlarmReceiver.class);
          PendingIntent pi=PendingIntent.getService(getApplicationContext(), 0, i, 0);

          mgr.setRepeating(AlarmManager.RTC,cal.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pi);
          Log.v("Timer","Timer");
        }

And then I have added a line to manifest as follows :

<receiver android:process=":remote" android:name=".AlarmReceiver"></receiver>

And then created a receiver class as follows:

public class AlarmReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        try {
            Toast.makeText(context, "broadcast received", Toast.LENGTH_SHORT).show();
            // Set up new intent
            Intent newIntent = new Intent(context, SendMessage.class);

            // Start new intent
            context.startService(newIntent);
        } catch (Exception e) {
            Toast.makeText(context, "There was an error somewhere, but we still received an alarm", Toast.LENGTH_SHORT).show();
            e.printStackTrace();
        }
    }
}

But for some reason when I test it on emulator I cannot receive any broadcast 🙁

could anyone please advice me what I am doing wrong?

Many thanks in advance

  • 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-07T02:12:10+00:00Added an answer on June 7, 2026 at 2:12 am

    You are using a PendingIntent for a service, but expect to receive a broadcast. Try using PendingIntent.getBroadcast().

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

Sidebar

Related Questions

I have created an extension method called AddGZip which looks like the following: public
I have created a class library called AddServiceLibrary in which I have a method
We have repositories which have a Save method. They also throw a Created event
I have created a Webpage which will post as post method..not as get method.
I have created a custom shipping method to show depo-names from which customers will
I have created a class which extends Gallery. There is no onCreate() method in
I have created a class called SimpleCanvas which extends the JPanel class, and I
I have created a console application in C# and there is main method (static)
I have created a Custom preference which has the following constructor public CoordinatesPreference(Context context,
I have created a dialog which can be called from anywhere by supplying a

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.