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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:29:43+00:00 2026-06-12T11:29:43+00:00

I get my Broadcast receiver to set a recurring alarm, to fire up a

  • 0

I get my Broadcast receiver to set a recurring alarm, to fire up a service. Unfortunately this does not result in the service being called repeatedly (based on logcat). I’ve experimented with different values for the time interval too. Can someone help? (I’m testing through Eclipse on Android 3.2 Motorola xoom)

Below is the code for the Broadcast receiver.

    alarm = (AlarmManager) arg0.getSystemService(Context.ALARM_SERVICE);
    Intent intentUploadService = new Intent (arg0, com.vikramdhunta.UploaderService.class);

    Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.SECOND, 3);

    PendingIntent pi = PendingIntent.getBroadcast(arg0, 0, intentUploadService , 0);
    alarm.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 5, pi);

Below is the code for the Service class

    public UploaderService()
    {
        super("UploaderService");
        mycounterid = globalcounter++;
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        synchronized(this)
        {
            try
            {
                for (int i = 1;i < 5;i++)
                {
// doesn't do much right now.. but this should appear in logcat
                    Log.i(TAG,"OK " + globalcounter++ + " uploading..." + System.currentTimeMillis());

                }
            }
            catch(Exception e)
            {

            }
        }   
    }
     @Override
        public void onCreate() {
            super.onCreate();
            Log.d("TAG", "Service created.");
        }


        @Override
        public IBinder onBind(Intent arg0) {
            return null;
        }
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) 
    {
        Log.i(TAG, "Starting upload service..." + mycounterid);
        return super.onStartCommand(intent,flags,startId);
    }
  • 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-12T11:29:44+00:00Added an answer on June 12, 2026 at 11:29 am

    Ok Looks like I got this one. Two changes were needed –
    1 – i made a mistake of using PendingIntent.getBroadcast when I needed to do getService instead (hell, who knew!)
    2 – In getService, I should have supplied PendingIntent.FLAG_UPDATE_CURRENT in the end instead of 0. FLAG_ONE_SHOT did not work. I guess since the interval is only 5 seconds, this is the right way.

    Now I get the right service/function to be called every 5 seconds. Hurray!

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

Sidebar

Related Questions

OK, so I have a broadcast receiver get called and in the onReceive() method
In a service, when sending smses in a loop with a broadcast receiver listening
In mainactivity I have Broadcast Receiver, pending intent, and alarm manager. It triggers as
Im trying to set an alarm that will send an intent to a broadcast
I have been able to get my BroadcastReceiver running with this: <receiver android:name=.AlarmReceiver android:enabled=true
I have set up a Broadcast Receiver to capture SMS messages. The Class display
I have a broadcast receiver in my program to get react to the battery
I have an Android service which sends broadcast intents. I'm trying to get those
How to set keyword to initiate Broadcast Receiver from text message? I got my
I want to install an apk file and set a broadcast-receiver in order to

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.