|
【Android】
EC-R3328PC androi系统 通过Android的开机广播设置的开机自启动但是没有生效
发表于 2020-10-20 10:08:13
浏览:7116
|
回复:3
打印
只看该作者
[复制链接]
楼主
通过Android的开机广播设置的开机自启动但是没有生效
2 K0 k6 `0 k1 W( Q
/ L( y% {* f" Y1 R4 |: i# M" lpublic class BootBroadcastReceiver extends BroadcastReceiver {3 v3 b. K i2 `6 P0 J: y3 O
1 _! w- ]) q- r! ?2 B$ q
@Override
: S$ T4 V- T# Q! Q public void onReceive(final Context context, Intent intent) {8 i: U/ F: D* v' |6 L1 Y2 a1 k
new Thread(new Runnable() {- E8 k3 D/ `* \% F7 d
@Override
- {3 \% A0 ~ _* M% C1 O public void run() {
; z! X! S# ~$ J; { try {
. c% ~* Z& A* C0 \( @5 J Thread.sleep(1000 * 30);
, X7 _) Q6 M. D Intent bootIntent = context.getPackageManager().getLaunchIntentForPackage("com.dnt.infraredshelf");
+ i% S: C1 f6 W4 o6 E context.startActivity(bootIntent);
5 L1 a0 C$ I, J2 Y: s/ [ } catch (InterruptedException e) {
2 r! _7 f# l6 I: T! p; y1 I! T e.printStackTrace();# h; W. c3 R) a7 m% V* S! h2 u! p
}' G2 e4 f; Z. d' u( \
}' P. ^! a. E- \% u$ N; p1 @
}).start();% b8 j8 D) \5 e5 b6 A6 l
}5 s, j; S$ H; E( n$ B1 i2 V6 t" Y
}
% F0 c3 b# N |" y! S2 ~& r" O) M <receiver android:name=".receive.BootBroadcastReceiver">& {1 r4 H# I8 D6 A! Q" ^- k
<intent-filter>' F$ a8 j8 J& n$ m; ~
<action android:name="android.intent.action.BOOT_COMPLETED" /> V" `8 h" D+ t( c
4 \0 \+ k5 Q# n( @# h7 z0 E8 M" t <category android:name="android.intent.category.LAUNCHER" />, G0 {8 m$ z+ v( v4 e7 A7 q
</intent-filter>
( ?8 `% k2 x( B: z </receiver> |
|