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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:34:46+00:00 2026-05-28T23:34:46+00:00

How do I periodically broadcast an event after user has installed my application. I

  • 0

How do I periodically broadcast an event after user has installed my application.

I have implemented a broadcast receiver which will trigger a task onReceive. Now I need to periodically broadcast this event, so that the task will be executed periodically.

I know I need to use AlarmManager.
The code is somewhat like this.

Intent intent = new Intent(this, MyBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
        this.getApplicationContext(), 234324243, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC, 0, 5*1000, pendingIntent);

Q1) Where do I place this code if I do not have any Activity? Do I implement this as a service?

Q2) What should be the intent-filter be for my manifest in such a “self created event”?

PS: Actually my current broadcast receiver is waiting for the connectivity change event. The task is to periodically attempt/try to access the internet. But I cannot solely rely on connectivity change to trigger this task. That’s why I need a timer which will either fire this event or trigger the method in onReceive().
I know in this case my intent-filter will be “android.net.conn.CONNECTIVITY_CHANGE”

  • 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-28T23:34:46+00:00Added an answer on May 28, 2026 at 11:34 pm

    Q1) Where do I place this code if I do not have any Activity?

    You need to implement an activity. Nothing of your application will run on Android 3.1+ until the user has launched your activity.

    So, you run this code:

    • The first time the user runs your activity

    • On a reboot (via a BOOT_COMPLETED BroadcastReceiver)

    • In the future when the user runs your activity, if you have determined that no broadcasts have gone out in too long, because the user force-stopped your application

    Also, get rid of getApplicationContext(), as you should not need it here.

    Q2) What should be the intent-filter be for my manifest in such a “self created event”?

    You do not need one, as your Intent identifies the component.

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

Sidebar

Related Questions

Consider an application which periodically executes a background task via setTimeout / setInterval .
Summary: I periodically get a .NET Fatal Execution Engine Error on an application which
A message box periodically pops up with the title Event Notification Application and the
I have a script which needs to periodically start programs out of a array
I have a Silverlight application where I periodically load more data and add it
I have to send sms periodically through my android application to a certain group
I have the following timer which periodically updates my page: var refreshId = setInterval(function()
I need to periodically query the event logs on a handful of servers and
Eclipse Helios periodically starts running a job which displays Computing additional info. During this
I have a method that periodically (e.g. once in every 10 secs) try 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.