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

The Archive Base Latest Questions

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

In Service I want to register BroadcastReceiver for android.net.wifi.WIFI_STATE_CHANGED public void onCreate() { super.onCreate();

  • 0

In Service I want to register BroadcastReceiver for android.net.wifi.WIFI_STATE_CHANGED

public void onCreate() {
        super.onCreate();

        final IntentFilter filter = new IntentFilter("android.net.wifi.WIFI_STATE_CHANGED");      

        MyReceiver myreceiver = new MyReceiver();

        // Register the receiver so that your service will listen for broadcast
        registerReceiver(myreceiver , filter);      

everything is good and works but after wifi state has changed for example is disconnected I want that is activated again in 5 minutes for 1 minute and then disconnected again. And after 5 minutes activated again for 1 minute. Generally connect after 5 minutes for just 1 minute and disconnect again…

I try this with AlarmManager but I am having problems how to achive that is connected after 5 minutes for 1 minute and then disconnect.

My code which is not what i try to do. It is not connected and then disconnected :

AlarmManager alarmMgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
            Intent alarmIntent = new Intent(this, WifiReceiver.class);
            PendingIntent pendingAlarmIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, alarmIntent, 0);

            // start in 5 minutes and rest in 1 minutes interval
            alarmMgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, 5*60*1000, 1*60*1000,  pendingAlarmIntent);

How can i do this? I AlarmManager correct way

  • 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-15T11:13:00+00:00Added an answer on June 15, 2026 at 11:13 am

    Use some timers to do it in your service…

    boolean delayedAgain = false;
    long newDelayedTimeFromNow;
    private Handler mHandlerTime = new Handler();
    ////////////////////// 
    Runnable  mUpdateTimeTask = new Runnable() {             
        public void run() {
            if(delayedAgain)
            {
    
            }
            else
            {
    
        }
    }; 
    ///to start timer 
          mHandlerTime.removeCallbacks(mUpdateTimeTask);
          mHandlerTime.postDelayed(mUpdateTimeTask, gps_interval); 
    

    SO you can determine one timer for 5 min to switch WIFI on and other for 6 min to switch off… Play with boolean dealyedAgain to make it… f.e. when first is out off 5 min change bool to true, and second will go when run ti if(..== true)

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

Sidebar

Related Questions

I want to make a WCF timer service where clients can register in order
I want to be able to register two alarms to the same BroadcastReceiver. However,
For example I want to register all classes with Service attribute using StructureMap [Service]
I register the Service & Provider with some IoC tool(e.g. StructreMap) public interface IProvider
I have an asp.net web service that I want to consume from another asp.net
I want to be able to inject model state into a service. Service public
Let's say I want a system where 5 people want to register a service
I'm having some problem consuming REST Service and want to figure out what I'm
You've pushed a code update to a daemontools service and want to restart it
I have web service which i want to use to upload image to the

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.