|
【Android】
程序设置的有开机自启动,但是没有生效
发表于 2020-10-20 09:45:16
浏览:6359
|
回复:0
打印
只看该作者
[复制链接]
楼主
通过Android的开机广播设置的开机自启动但是没有生效& |/ R. p( W9 C% \! e$ F3 X9 q
' P/ y6 O; I& v6 o8 j, N
public class BootBroadcastReceiver extends BroadcastReceiver {
: g4 E! S- V1 R, G1 z- b d5 ]" R+ r
@Override
5 H. f" t* _7 }! i- ?8 } public void onReceive(final Context context, Intent intent) { B4 K2 ?' X# _( H; f, e5 f- x
new Thread(new Runnable() {2 ^. f& P# ^9 ?4 k- U' E5 H
@Override9 t- d+ u: u; P5 \% L7 B1 a* W' |' s
public void run() {
. Y# [% H6 ~ W6 r try {$ e: N6 k* r7 i6 q+ x" `6 D3 V
Thread.sleep(1000 * 30);
- ]+ N: ^5 ^" s w! E0 R' ? Intent bootIntent = context.getPackageManager().getLaunchIntentForPackage("com.dnt.infraredshelf");
2 m' o V; L: k: B1 s7 l* ^ context.startActivity(bootIntent);
5 |) ?* A% @+ B% V* i+ M } catch (InterruptedException e) {1 H. I1 Y% I; w/ |' o! g @
e.printStackTrace();
; i( n5 s9 O8 J# a3 F% w6 w }% n5 \1 q- C: U& e+ X; m; f
}1 R) S! a& w/ d
}).start();
6 m# n& d( h2 h _- h: G3 r }% y3 A `0 C6 _' D6 C
}
! P! \) d3 A: t" x+ ^0 ~ q3 P |
|