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");
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…