|
【Android】
程序设置的有开机自启动,但是没有生效
发表于 2020-10-20 09:45:16
浏览:6161
|
回复:0
打印
只看该作者
[复制链接]
楼主
通过Android的开机广播设置的开机自启动但是没有生效" u5 D. r8 g$ l" P* _2 G
" z1 ^5 [+ W+ S; q
public class BootBroadcastReceiver extends BroadcastReceiver {
6 \8 L& q& e+ `) [* p" m: L
w0 V9 X* M) W/ ?0 F @Override# y$ ]3 O6 c$ U5 y2 z0 f
public void onReceive(final Context context, Intent intent) {$ v$ |! J* x9 d
new Thread(new Runnable() {2 g. Z/ v: `" e, z
@Override$ \3 K0 `4 C m$ t! O7 H
public void run() {9 y) W+ x* C* Q( n! B! P! {. \. [7 q
try {7 f, v( v0 D8 k
Thread.sleep(1000 * 30);
: r5 M4 A) i& l2 m7 p' x! J Intent bootIntent = context.getPackageManager().getLaunchIntentForPackage("com.dnt.infraredshelf");
& K# b' w( W/ J. n( P context.startActivity(bootIntent);
9 s& I9 M* h+ z5 g' i# v9 R9 ?1 Y' |' N } catch (InterruptedException e) {
, v+ h J8 R7 Y: ^- Z e.printStackTrace();
/ T6 g, B4 a: a. y7 _* z } Y3 x" y" i# f3 u
}
& C ^* |6 n# ^9 ], o }).start(); P6 E( ^, J0 v5 a6 U" E% q! K
}( ?( {7 k* I7 U
}
7 y; u" m3 E3 P3 f |
|