|
【Android】
程序设置的有开机自启动,但是没有生效
发表于 2020-10-20 09:45:16
浏览:6277
|
回复:0
打印
只看该作者
[复制链接]
楼主
通过Android的开机广播设置的开机自启动但是没有生效/ K, B( w5 k# f9 d: e; ], r' r
( |0 r: `5 N, ^$ J- r* b& G
public class BootBroadcastReceiver extends BroadcastReceiver {
+ T0 H- Z1 `/ _; t& m1 ~* a4 K. _2 \1 T H
@Override
' G* G- j& ^) s% o- c8 C+ X public void onReceive(final Context context, Intent intent) {6 P9 u9 C/ I8 l, K# Y
new Thread(new Runnable() {
0 @, n/ s4 U* }: Z; e @Override( i8 O0 t7 d- t& ]
public void run() {$ l6 M9 d7 S8 |! _, c6 Z( L
try {1 m- J7 z* b1 ~: D
Thread.sleep(1000 * 30);
5 G8 q( E9 A% ] Intent bootIntent = context.getPackageManager().getLaunchIntentForPackage("com.dnt.infraredshelf");
9 n- X) x4 I/ u$ ^1 ?, h context.startActivity(bootIntent);
b. i( t1 a4 {, H/ I } catch (InterruptedException e) {( ~2 k* p8 W- d: s$ q% a
e.printStackTrace();9 K. ]6 n7 r! X' x G$ ~
}
, q3 l8 {' Q" i+ I8 m" m( }. X }
7 F, {& L& m W. C5 i; ~5 ^ }).start();
" G0 I0 a5 `# ~! h, n3 a. i3 ] }
( E! h5 N5 a. S}
# j0 s, f' P! F# m4 ?# U" u5 m3 X |
|