Android Boot program (custom Oh!) )

Source: Internet
Author: User

The source code is downloaded in the personal file:


Here is the configuration file:

<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "Http://" Package= ""Android:versioncode= "1"Android:versionname= "1.0" > <uses-SDK Android:minsdkversion= "8"android:targetsdkversion= "/>" <uses-permission android:name= "Android.permission.RECEIVE_BOOT_COMPLETED" > </uses-permission&    Gt <Application Android:icon= "@drawable/ic_launcher"Android:label= "@string/app_name" > <Activity Android:name= ""Android:label= "@string/app_name" > <intent-filter> <action android:name= "Android.intent.action.MA In "/> <category android:name=" Android.intent.category.LAUNCHER "/> </intent-filter&        Gt </activity> <receiver android:name= "" > <intent-filter         > <action android:name= "Android.intent.action.BOOT_COMPLETED"/> </intent-filter> </receiver> </application></manifest>

This is the service class;;ImportAndroid.content.BroadcastReceiver;ImportAndroid.content.Context;Importandroid.content.Intent;/*** Inherit a service that catches the boot first service * *@authorCatherine.brain * **/ Public classStartreceviverextendsBroadcastreceiver {/**define an action*/    Static FinalString ACTION = "Android.intent.action.BOOT_COMPLETED"; @Override Public voidOnReceive (Context context, Intent Intent) {if(Intent.getaction (). Equals (ACTION)) {Intent sayhellointent=NewIntent (context, mainactivity.class);            Sayhellointent.addflags (Intent.flag_activity_new_task);        Context.startactivity (sayhellointent); }    }}

Here are the main classes:;;ImportAndroid.os.Bundle;ImportAndroid.os.Handler;ImportAndroid.view.Window;ImportAndroid.view.WindowManager;ImportAndroid.widget.ImageView;/*** This is a application of the start phone * *@authorCatherine.brain **/ Public classMainactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); //Setcontentview (r.layout.activity_main);requestwindowfeature (Window.feature_no_title); GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN        ); /**Customize a picture, and then load*/ImageView Image=NewImageView ( This);        Setcontentview (image);        Image.setbackgroundresource (R.drawable.ic_launcher);    Mythread.start (); } Thread MyThread=NewThread () { Public voidrun () {Try{sleep (5000); } Catch(interruptedexception e) {//TODO auto-generated Catch blockE.printstacktrace (); } finally{myhandler.sendemptymessage (EXIT);    }        };    };  Public Static Final intEXIT = 0x0001; Handler MyHandler=NewHandler () { Public voidhandlemessage (android.os.Message msg) {Switch(msg.what) { CaseEXIT:/**The time is to shut down*/System.exit (0);  Break; default:                 Break;    }        }; };}

Android Boot program (custom Oh!) )

Related Article

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: 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.