|
【Android】
EC-R3328PC androi系统 通过Android的开机广播设置的开机自启动但是没有生效
发表于 2020-10-20 10:08:13
浏览:6503
|
回复:3
打印
只看该作者
[复制链接]
楼主
通过Android的开机广播设置的开机自启动但是没有生效
! o. K. O7 Q& U3 S# |- B: Y( P* T% @3 p$ M! P
public class BootBroadcastReceiver extends BroadcastReceiver {
& J( f: `1 E4 |; W9 g
w* F5 W; k$ v# }# }/ {' c @Override
C/ R W: n6 T, x: B; j public void onReceive(final Context context, Intent intent) {0 F$ V, l4 ]- q7 J% A
new Thread(new Runnable() {
1 T5 N" b v( t7 c+ ]0 X& E @Override7 p6 ?$ k4 O B0 w# [
public void run() {
# D5 M* S+ K( K$ S" l# N, Q; H try {
- E9 q6 X1 d$ Q$ ~- k6 R Thread.sleep(1000 * 30);- F/ H7 Y- L& I& i
Intent bootIntent = context.getPackageManager().getLaunchIntentForPackage("com.dnt.infraredshelf");
) o; K% O& g1 {3 d( q' R context.startActivity(bootIntent);
7 u: j5 s3 `5 Q" ]( J } catch (InterruptedException e) {
0 \; Z" P, n6 Z% d# i0 S& y; p! T2 w e.printStackTrace();9 d: V. w! r: B
}% o$ x6 ?4 h" K
}! E6 O k* D: i7 m7 A: m
}).start();
) G* v+ |3 G0 r& @; @" O; j }
: C* c6 g B+ `, T, H* n}7 a4 V! R1 b# [6 q
<receiver android:name=".receive.BootBroadcastReceiver">
1 }; J" H6 G, J: ? ~ <intent-filter>0 f) L; ? ?* M* _
<action android:name="android.intent.action.BOOT_COMPLETED" /># L- b( i! J. g3 `
% t5 C: {- i6 y( X: Z% ~8 A
<category android:name="android.intent.category.LAUNCHER" />
4 a; h# S+ l; t: n: T/ P </intent-filter>
0 s z) X, p9 a) F </receiver> |
|