|
【Android】
EC-R3328PC androi系统 通过Android的开机广播设置的开机自启动但是没有生效
发表于 2020-10-20 10:08:13
浏览:7161
|
回复:3
打印
只看该作者
[复制链接]
楼主
通过Android的开机广播设置的开机自启动但是没有生效
& s6 H6 a: {+ l" ^
/ k) v: c/ }& J& u" b: rpublic class BootBroadcastReceiver extends BroadcastReceiver {
. t! n' o6 V7 I& ]
( `& u( Z$ o3 Z+ [1 j @Override
# m1 K' k/ e* O6 }& Y public void onReceive(final Context context, Intent intent) {
- }" i4 e3 S( t0 y( H2 ~2 V new Thread(new Runnable() {
1 {# [2 Y0 {! W7 ^ @Override
1 @) L; y9 e5 X- @% I2 B public void run() {4 t% h" ?5 v* [
try {
0 Y- C1 H# l! z Thread.sleep(1000 * 30);* l4 X# Y) M5 Z1 x
Intent bootIntent = context.getPackageManager().getLaunchIntentForPackage("com.dnt.infraredshelf");/ K7 H- E* o3 j* s; [+ j
context.startActivity(bootIntent);- {7 g$ e* ^2 t- p
} catch (InterruptedException e) {
) F" ^- | ^, m$ Z e.printStackTrace();
' g) e u4 t- r# }& ~- r5 B }; p/ ^9 f& c( q- t+ O- j
}
+ ~, w% _/ i' T$ e }).start();+ j' X. w( ?" {
}
) i! I. W, l; q" T* y2 f6 ^$ ]' ~}* T3 L! ^9 j* Z& k# V
<receiver android:name=".receive.BootBroadcastReceiver">
: V4 E8 b) X: u/ B+ H <intent-filter>
K' k5 U3 d+ M/ P. |1 @ <action android:name="android.intent.action.BOOT_COMPLETED" />( ?' n) I% W% _) V# Q
+ H m# r6 Z& |, o9 [ <category android:name="android.intent.category.LAUNCHER" />2 b; y6 Y* i" d
</intent-filter>
5 P1 z8 F8 d* |: I% m; N( M </receiver> |
|