android 已root 添加启动项

1.创建BroadcastReceiver

    public class MyReceiver extends BroadcastReceiver {   

    @Override
    public void onReceive(Context context, Intent intent) {

     Intent myIntent = new Intent(context, YourService.class);
     context.startService(myIntent);

    }
} 

2.AndroidManifest.xml注册OnReceive,并添加权限


        
            
                
            
        

    

    
     

 

方式一:如果使用superSu授权工具,在/system/su 下添加shell脚本(脚本文件名开头的数字表示执行顺序)(别忘了设置可执行),开机后会自动运行脚本.
方式二:修改boot.img在init.rc中添加相应service(具体可问度娘或google).
方式三:在app中监听_"boot_complete" 的 broadcast 执行命令.

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(android 已root 添加启动项)