|
【Android】
EC-R3328PC androi系统 通过Android的开机广播设置的开机自启动但是没有生效
发表于 2020-10-20 10:08:13
浏览:7275
|
回复:3
打印
只看该作者
[复制链接]
楼主
通过Android的开机广播设置的开机自启动但是没有生效) ?5 M2 R( w& _/ y
' F: J! o4 u% ^' z1 cpublic class BootBroadcastReceiver extends BroadcastReceiver {
4 ]- B S9 A* p' h5 j, M% J' t
. _* i+ o, Z% F& [; G @Override
0 j$ E. U& _: \4 a$ N5 K$ [ public void onReceive(final Context context, Intent intent) {9 ], x8 y7 p5 W! q, a0 n' c
new Thread(new Runnable() {
# l' X( p& k. W( E! U @Override
8 A& Z1 G5 b" R+ X- }" j public void run() {
; D. M" J- A$ f f m2 {" L try {8 X& p" e/ ^- v
Thread.sleep(1000 * 30);
3 `, T: {" y1 k Intent bootIntent = context.getPackageManager().getLaunchIntentForPackage("com.dnt.infraredshelf");
6 \3 S) o7 Y! }% k3 T context.startActivity(bootIntent);; R5 |9 x5 e1 ~; Z7 _+ L
} catch (InterruptedException e) {
: T- {. y6 S1 J4 `! p3 T2 y; Q! @ e.printStackTrace();
- |/ x! D0 Z+ ]) P; f W }
/ ~$ U0 H* ~2 |4 Z }
6 j! W5 u+ w# c* Z" D }).start();' M" S$ h% \* s
}
2 B6 y$ o; i. i& g1 ?8 B}( \6 p6 c. I! R L7 K5 y( o" c9 ^, L
<receiver android:name=".receive.BootBroadcastReceiver">2 a. U' i" [# q0 E9 e* y ]2 \
<intent-filter>2 r9 r- ]6 [9 N
<action android:name="android.intent.action.BOOT_COMPLETED" />
$ x o% c" m( D$ t: h
- m; G, ~5 V9 P9 E# Z <category android:name="android.intent.category.LAUNCHER" /># a) Q+ M9 q; P* f8 U+ z" i
</intent-filter>) \+ L' u5 t- U [! {8 h! f: W& e" d
</receiver> |
|