apk开机自启动

//使apk开机自启动一般步骤:
//1、在apk源码里添加BroadcastReceiver.java
package com.mstar.test.bitmap;//包名

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class BootReceriver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent arg1) {
        // TODO Auto-generated method stub
        Log.d("TestBitmapActivity","come in onReceive...");
        //Intent intent2 = new Intent(context,TestBitmapActivity.class);这里传activity的类名。
        Intent intent2 = new Intent(context,TestBitmapActivity.class);
        intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent2);
        Log.d("TestBitmapActivity","start tvapk rootActivity now...");
    }

}
2、在AndroidManifest.xml里添加
<!-- Register BOOT COMPLETED BroadCast -->
        <receiver android:name=".BootReceriver" >
            <intent-filter >
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

你可能感兴趣的:(apk开机自启动)