• Android开机程序(自定义哦!)


    源码下载在个人文件里面:

    StartApp.rar

    这是配置文件:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.android.startapp"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="19" />
    
        <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" >
        </uses-permission>
    
        <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" >
            <activity
                android:name="com.android.startapp.MainActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
    
            <receiver android:name="com.android.reserver.StartReceviver" >
                <intent-filter>
                    <action android:name="android.intent.action.BOOT_COMPLETED" />
                </intent-filter>
            </receiver>
        </application>
    
    </manifest>

    这是服务类

    package com.android.reserver;
    
    import com.android.startapp.MainActivity;
    
    import android.content.BroadcastReceiver;
    import android.content.Context;
    import android.content.Intent;
    
    /**
     * 继承一个服务,扑捉开机的第一个服务
     * 
     * @author Catherine.Brain
     * 
     * */
    public class StartReceviver extends BroadcastReceiver {
        /** 定义一个action */
        static final String ACTION = "android.intent.action.BOOT_COMPLETED";
    
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(ACTION)) {
                Intent sayHelloIntent = new Intent(context, MainActivity.class);
                sayHelloIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(sayHelloIntent);
            }
        }
    
    }

    这里是主要类:

    package com.android.startapp;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.os.Handler;
    import android.view.Window;
    import android.view.WindowManager;
    import android.widget.ImageView;
    
    /**
     * this is a application of the start phone
     * 
     * @author Catherine.Brain
     * */
    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(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);
            /** 自定义一个图片,然后加载 */
            ImageView image = new ImageView(this);
            setContentView(image);
            image.setBackgroundResource(R.drawable.ic_launcher);
            myThread.start();
        }
    
        Thread myThread = new Thread() {
    
            public void run() {
                try {
                    sleep(5000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } finally {
                    myHandler.sendEmptyMessage(EXIT);
                }
            };
        };
        public static final int EXIT = 0x0001;
        Handler myHandler = new Handler() {
            public void handleMessage(android.os.Message msg) {
                switch (msg.what) {
                case EXIT:
                    /** the time is to shut down */
                    System.exit(0);
                    break;
    
                default:
                    break;
                }
            };
        };
    }
    一切只是为了充实自己!!stay hungry and stay foolish!!
  • 相关阅读:
    团队如何限制合适的在制品(WIP)数量
    cssui库,自适应ui库
    npm i 报错 nodegyp 在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。
    20192413宗俊豪 202120222 《网络与系统攻防技术》实验五实验报告
    数据结构笔记——查找
    数据结构笔记——图
    js Object 复习
    js String
    软件工程相关术语缩写
    Angular 依赖注入的错误 NullInjectorError, No provider for XXX
  • 原文地址:https://www.cnblogs.com/Catherine-Brain/p/4030602.html
Copyright © 2020-2023  润新知