|
【Android】
EC-R3328PC androi系统 通过Android的开机广播设置的开机自启动但是没有生效
发表于 2020-10-20 10:08:13
浏览:7117
|
回复:3
打印
只看该作者
[复制链接]
楼主
通过Android的开机广播设置的开机自启动但是没有生效
3 D5 n# | d2 d! k% B) i3 T' j9 r, y& E& f; F @
public class BootBroadcastReceiver extends BroadcastReceiver {
3 I9 Z- u0 D9 ?' {# m9 S) l/ B- k+ g V
@Override- s4 t' A2 |# c8 R5 v8 i
public void onReceive(final Context context, Intent intent) {
+ i1 V& [ _7 D* a8 V, R new Thread(new Runnable() {; ~7 j4 }$ G3 L6 d' Q
@Override+ a* R( X) o! x1 {% @6 W# V# |
public void run() {* p* M( i' D# _3 P% {
try {
# }: _ l5 `- y* s Thread.sleep(1000 * 30);9 O+ I' s: t0 y8 T/ k- F
Intent bootIntent = context.getPackageManager().getLaunchIntentForPackage("com.dnt.infraredshelf");4 u6 Z" U- V/ A6 k& H
context.startActivity(bootIntent);
( {" K0 A, b$ J* c3 R# o } catch (InterruptedException e) {6 h) L8 @. H4 w& x5 v8 n! }
e.printStackTrace();$ W) R' Z4 n* }7 j7 {
}; ?3 X3 F) w1 v5 I
}& p) j" C) H) E5 M# w
}).start();' y; Q9 C# @4 m! K: i. W9 r7 C/ b$ v
}7 t n( a" Q$ M9 t- W7 z
}8 Z7 H( o* C+ ]5 a" A' a. `
<receiver android:name=".receive.BootBroadcastReceiver">
( z) j) H( {, \ <intent-filter>/ o$ o1 Z$ C0 x- r7 @9 Z
<action android:name="android.intent.action.BOOT_COMPLETED" />% F3 v2 t. Q, y5 k
5 S3 z0 d t& g8 h* X/ q <category android:name="android.intent.category.LAUNCHER" />7 A' N2 Q, @. u+ g
</intent-filter>" w& N- j. A( u& A$ n6 v
</receiver> |
|