2

I want to start service once i get BOOT_COMPLETE intent. In HTC explorer there are 2 options for reboot those are 'poweroff' and 'restart'. When i use 'restart' i am getting BOOT_COMPLETE intent properly. But when i use 'poweroff' not getting BOOT_COMPLETE intent so i am not able to start service. Is their any intent i can get only after reboot in HTC?

I have been surfing Google, could not find any hint. I am stuck please help me out

I used this code <action android:name="android.intent.action.BOOT_COMPLETED"/> in manifest but no use

Thanks in advance

1
  • Can you post the whole receiver section of your manifest and the code you use in the receiver. May 2, 2012 at 10:24

1 Answer 1

9

Some HTC devices can enable a "fast boot" feature that is more like a deep hibernation and not a real reboot and therefore should not give the BOOT_COMPLETE intent. Also make sure that the app is not installed on the SD card as it might not receive the BOOT_COMPLETED because of that.

This might also be interesting:

http://commonsware.com/blog/2011/07/13/boot-completed-regression-confirmed.html

http://arthurfmay.blogspot.jp/2011/06/broadcastreceiver-bootcompleted-and.html

And especially this where the "fast boot" option is being mentioned:

http://groups.google.com/group/android-developers/browse_thread/thread/56562e4de4919dc6

Edit:

How about simply using:

Intent.ACTION_SCREEN_ON

And you can then check if the service is running:

public static boolean ServiceRunning(Context cx) 
{   ActivityManager manager = (ActivityManager) cx.getSystemService(Context.ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE))
    {   if ("<<<service name goes here>>>".equals(service.service.getClassName()))
        {   return true;
        }
    }
    return false;
}

And if it isn't just start it:

public static void ServiceCheck(Context cx)
{   if(ServiceRunning(cx) == false)
    {   Intent svc = new Intent(".<<<Servicename>>>");
        cx.startService(svc);
        Log.i("Service-Check","Service Starting");
    }
    else
    {   Log.i("Service-Check","Service Existing");
    }
}   
1
  • Thanks a lot. I unchecked 'fast boot' option now i am getting Boot_complete intent. But i need one more thing how to get Boot_Complete with out disabling the 'fast boot' option in HTC desire.
    – Vani
    May 2, 2012 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.