80,351
社区成员
发帖
与我相关
我的任务
分享
reboot:
Intent i= new Intent( Intent.ACTION_REBOOT);
sendBroadcast( i );
shutdown:
Intent i= new Intent( Intent.ACTION_SHUTDOWN);
sendBroadcast( i );
AndroidManifest.xml:
.....
android: sharedUserId="android.uid.system">
....
<uses-permission android: name="android.permission.RECEIVE_BOOT_COMPLETED">
BootReceiver.java:
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context,Intent intent){
Intent i=new Intent(Intent.ACTION_RUN);
i.setClass(context, UpdateProgress.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}