Android mobile phone set up activity

Source: Internet
Author: User

1. Layout

Default HelloWorld layout

2. Class

Bootcompletereceiver
Package Lpc.com.project522;import Android.content.broadcastreceiver;import Android.content.context;import android.content.intent;/** * Created by Administrator on 2015/12/23. */public class Bootcompletereceiver extends Broadcastreceiver {    @Override public    void OnReceive (Context Context, Intent Intent) {        Intent =  new Intent (context,mainactivity.class);        Intent.setflags (Intent.flag_activity_new_task | intent.flag_activity_exclude_from_recents);        Context.startactivity (intent);    }}

  

3.

Manifest file
<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http://schemas.android.com/apk/res/ Android "package=" lpc.com.project522 "> <uses-permission android:name=" android.permission.RECEIVE_BOOT_ Completed "/> <application android:allowbackup=" true "android:icon=" @mipmap/ic_launcher "Android Oid:label= "@string/app_name" android:supportsrtl= "true" android:theme= "@style/apptheme" > <activ ity android:name= ". Mainactivity "> <intent-filter> <action android:name=" Android.intent.action.MAIN "/&G                T <category android:name= "Android.intent.category.LAUNCHER"/> </intent-filter> </activity&        Gt <receiver android:name= ". Bootcompletereceiver "> <intent-filter> <action android:name=" android.intent.action.b Oot_completed "/> </intent-filter> </receiver> </applicAtion></manifest> 

  

4, realize the effect, start the Mainactivity page of this app after booting



Android mobile phone set up activity

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.