Android Boot from start demo

Source: Internet
Author: User

Package Com.example.openstart;import Android.app.keyguardmanager;import Android.app.KeyguardManager.KeyguardLock; Import Android.content.broadcastreceiver;import Android.content.context;import Android.content.intent;import Android.util.log;public class Mpustartbroadcastreceiver extends Broadcastreceiver {/** * receive system boot complete broadcast * */@Overridepublic void OnReceive (Context context, Intent Intent) {//Cancel System lock screen Keyguardmanager Mkeyguardmanager = (Keyguardmanager) Context.getsystemservice (Context.keyguard_service); Keyguardlock Mkeyguardlock = Mkeyguardmanager.newkeyguardlock ("mainactivity"); Mkeyguardlock.disablekeyguard (); Intent = new Intent (context, mainactivity.class); Intent.setflags (Intent.flag_activity_new_task); Context.startactivity (intent);//Start Intent}}

Manifest.xml configuration

Register the receiving system to start the broadcast

<receiver android:name= "Com.example.openstart.MPUStartBroadcastReceiver" >            <intent-filter android: priority= "2147483647" >                <action android:name= "Android.intent.action.BOOT_COMPLETED"/>                < Category android:name= "Android.intent.category.HOME" >                </category>            </intent-filter>        </receiver>
Permission Additions

  <uses-permission android:name= "Android.permission.RECEIVE_BOOT_COMPLETED"/>    <uses-permission Android:name= "Android.permission.DISABLE_KEYGUARD"/>

receive_boot_completed system starts to complete the broadcast

Disable_keyguard Allow program to disable keyboard lock



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.