|
【Android】
EC-R3328PC androi系统 通过Android的开机广播设置的开机自启动但是没有生效
发表于 2020-10-20 10:08:13
浏览:4425
|
回复:3
打印
只看该作者
[复制链接]
楼主
通过Android的开机广播设置的开机自启动但是没有生效( S( A! L+ j i8 U
/ v' ~3 m/ J# p& e6 [8 o
public class BootBroadcastReceiver extends BroadcastReceiver {2 t6 I# C1 o$ h# ~
" l6 b; C. H# W @Override
$ g3 Z2 k, j4 ~1 ?6 S( B0 V public void onReceive(final Context context, Intent intent) {$ [1 B0 S5 q. }/ R2 l. ~! E
new Thread(new Runnable() {
9 K* c3 J( K* a4 f" K @Override% X, \: Y2 W; u) F
public void run() {6 ?5 n* T! w1 F& [
try {( b5 p, N4 M; U6 o( s/ k9 J7 c" h+ d
Thread.sleep(1000 * 30);5 p7 A0 p6 \5 F6 T& J5 o* W3 e
Intent bootIntent = context.getPackageManager().getLaunchIntentForPackage("com.dnt.infraredshelf");
6 e1 H, D* _3 K/ X. W context.startActivity(bootIntent);9 N( ?+ a% z' r1 N( ~6 b. Y
} catch (InterruptedException e) {; A, ?9 V( @$ D k, b
e.printStackTrace();
# o4 Y% m8 ^( L' t% D* ]! E1 O }& r e$ n/ l: m' c' P$ l
}
, u& Q$ k0 O- {" ^1 G# V$ P }).start();
5 P3 L' [" W8 w4 [( M7 H }# z, x8 W9 y" Z. }5 w
} h! y( Y4 t7 `* E- @# W! G
<receiver android:name=".receive.BootBroadcastReceiver">/ l3 y) n' J0 z& j' O
<intent-filter>
3 h, e. E& {" |" N$ v <action android:name="android.intent.action.BOOT_COMPLETED" />1 }% B( I1 ]5 ^2 H2 I" R) K w
4 b0 F( o; }2 ?- e <category android:name="android.intent.category.LAUNCHER" />
8 x; }' N1 V/ w! z- d8 S+ P, D </intent-filter>: D/ O7 z* V+ m- z' n$ ?
</receiver> |
|