|
【Android】
EC-R3328PC androi系统 通过Android的开机广播设置的开机自启动但是没有生效
发表于 2020-10-20 10:08:13
浏览:7119
|
回复:3
打印
只看该作者
[复制链接]
楼主
通过Android的开机广播设置的开机自启动但是没有生效
. r- k3 p4 b' Z; A$ ?; x6 m3 @* \/ k! v4 f, y* O. t6 ^, R
public class BootBroadcastReceiver extends BroadcastReceiver {
- g, |5 W1 {4 a u( E. ]4 h7 N8 |8 |
@Override
0 r' W! C' }6 i; \& m4 A' ~ public void onReceive(final Context context, Intent intent) {" y+ ~, Q S" w8 A$ O
new Thread(new Runnable() {* u `1 o; }! ]* P$ \- T' ]
@Override* c5 T2 q/ W6 s& S# ~
public void run() {; `. C" W8 M6 L$ |9 m
try {
3 M O; Q0 ?. z9 m7 c' Y3 l Thread.sleep(1000 * 30);
& f* O8 N2 t8 T, m Intent bootIntent = context.getPackageManager().getLaunchIntentForPackage("com.dnt.infraredshelf");
+ n; ~& r5 [+ o7 S% H8 o! {/ `6 ~4 t2 E context.startActivity(bootIntent);
) p a& `: m! g! V# A. n* V } catch (InterruptedException e) {; w. w% [! b0 E
e.printStackTrace();
* s, g$ F% v. d l. {" i: w }1 Z4 f. ?7 J/ {+ R& h! ]' s* F
}" R2 C" f: _1 s, o
}).start();
, N& t: w$ V9 E. ? }8 _3 M" d9 I( ~( @
}
: `1 d1 [1 c: K) U+ _ <receiver android:name=".receive.BootBroadcastReceiver">, D0 U1 e+ b n* {! {$ h
<intent-filter>
( w: X1 t* C, X6 f* K <action android:name="android.intent.action.BOOT_COMPLETED" />
4 U3 J. Z- \* x+ d- G8 o6 @: R1 `3 ^* @ z) A
<category android:name="android.intent.category.LAUNCHER" />
/ X" u5 B, {5 g |& _% }9 _; x' R5 [ </intent-filter>
g# j, x2 Z' R </receiver> |
|