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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:12:24+00:00 2026-05-30T14:12:24+00:00

In this segment of code I have an issue where I’m not sure what

  • 0

In this segment of code I have an issue where I’m not sure what to set the context for setRecurringAlarm(). In this code example I put this but I’m not sure if that’s right.

public class AlarmReceiver extends BroadcastReceiver {

private static final int INTERVAL = 15*1000; // check every 15 seconds

    @Override
    public void onReceive(Context context, Intent intent) {
        if(intent.getAction() != null) {
            if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
                Log.v(TAG, "BroadcastReceiver - Received Boot Completed; Set Alarm");

                setRecurringAlarm(this);
            }else{
                Log.v(TAG, "BroadcastReceiver - Received " + intent.getAction());
            }
        }else{
            Log.v(TAG, "BroadcastReceiver - Received AlarmService");
        }
    }

    private void setRecurringAlarm(Context context) {
        Intent receiver = new Intent(context, AlarmReceiver.class);
        PendingIntent recurringDownload = PendingIntent.getBroadcast(context, 0, receiver, PendingIntent.FLAG_CANCEL_CURRENT);
        AlarmManager alarms = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
        alarms.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), INTERVAL, recurringDownload);
    }
}
  • 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-30T14:12:25+00:00Added an answer on May 30, 2026 at 2:12 pm

    You’ve got your context in onReceive(Context context, Intent intent), use it.

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

Sidebar

Related Questions

I have seen this code segment for opening a native activity that chooses one
I'm really unsure if this is even possible but we have an issue where
I have performance issues in this code segment which I think is caused by
This is a segment of code I have for setting the masterpassword: private void
I have this segment of code , a lot of things skipped for brevity
I have a C code segment like this struct test{ char *ptr; } What
I have this segment of Scala code which defines an ordering and applies it
I have this code segment in which I am opening/closing a file a number
If we have this segment of code: char *i=Hello; cout<<i<<endl; cout<<*i<<endl; cout<<&i<<endl; cout<<*&i<<endl; cout<<&*i<<endl;
I just found that, in Adobe Dreamweaver CS3, this code segment seems fine in

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.