|
【Android】
EC-R3328PC androi系统 通过Android的开机广播设置的开机自启动但是没有生效
发表于 2020-10-20 10:08:13
浏览:7251
|
回复:3
打印
只看该作者
[复制链接]
楼主
通过Android的开机广播设置的开机自启动但是没有生效
, ]1 y$ V: j F0 h) W
g& M9 E8 K% }; ~2 v6 \public class BootBroadcastReceiver extends BroadcastReceiver {
& w; S2 \) s9 q- Y8 \' W$ O- T1 Y9 i, S/ Z" S1 }! S
@Override4 I3 l1 f* a& }5 J s. O
public void onReceive(final Context context, Intent intent) {
3 h! _7 u8 l' \% l' c5 A$ f0 |: ? new Thread(new Runnable() {' `3 Q7 L; Z! r8 n4 u7 s* G
@Override, g1 v! G7 P+ `% ?+ `+ b; \
public void run() {& |. O8 Z, N" |) f3 [
try {1 b) [) B5 O+ r* e7 Z
Thread.sleep(1000 * 30);3 e8 t6 O" |( `0 i3 O2 I- u0 \- t
Intent bootIntent = context.getPackageManager().getLaunchIntentForPackage("com.dnt.infraredshelf");7 T4 o7 N4 C! v* S; O
context.startActivity(bootIntent);
5 m7 n" w) d' W* r9 }3 ] } catch (InterruptedException e) {
6 Z6 t" v! e% x! q3 W) ^) V# K8 J e.printStackTrace();
. a2 G$ ?: {# O) T }
' ~0 A7 P' H% p" ? }
! g6 _2 ~; W5 W4 `5 o }).start();
5 `/ }4 w5 W* j" M# Y }9 \" G( b. S& f3 h8 Y& [6 x
}1 T& S! j/ P6 m; N i! P- g
<receiver android:name=".receive.BootBroadcastReceiver">5 h" Y3 R1 Y8 Y( N
<intent-filter>! R1 N* N! b" o
<action android:name="android.intent.action.BOOT_COMPLETED" />
' ~2 e# Y3 C/ F( p6 r5 ]5 B5 d5 _7 B" d7 w3 E" b' M+ _
<category android:name="android.intent.category.LAUNCHER" />
3 H& @# ]3 I b+ v </intent-filter>
# w, |1 _" M6 T5 s) f7 [ </receiver> |
|