|
【Android】
EC-R3328PC androi系统 通过Android的开机广播设置的开机自启动但是没有生效
发表于 2020-10-20 10:08:13
浏览:7366
|
回复:3
打印
只看该作者
[复制链接]
楼主
通过Android的开机广播设置的开机自启动但是没有生效" _6 b0 O* o' Z6 l6 G0 a
4 M0 b# ~3 M1 f4 ~+ Z L4 A
public class BootBroadcastReceiver extends BroadcastReceiver {# d/ ^9 A" r4 j" d* b* s/ e
% B. a% q9 ?* l- e# E( x
@Override
1 y: M) Z1 A2 s7 J5 X% T. R# H1 I public void onReceive(final Context context, Intent intent) {
; T! T. F8 w, H0 v, Y new Thread(new Runnable() {8 N3 b2 l- l6 n
@Override/ q2 q0 K: L2 Q/ m
public void run() {
1 G# C$ q/ L$ ] try {8 w: T4 K( K7 E$ h& t* Y
Thread.sleep(1000 * 30);) X1 i2 ^9 A6 z! a
Intent bootIntent = context.getPackageManager().getLaunchIntentForPackage("com.dnt.infraredshelf");+ P0 g( T3 Z. P3 w
context.startActivity(bootIntent);$ E# e, o! j! \6 u. o
} catch (InterruptedException e) {6 |5 ~3 w$ A' U3 E; y9 G6 }$ y
e.printStackTrace();' k4 r* l& I; {) |- E* |- m
}) U" a. I) p* g' C' ?5 ?
}% s) s, u! q6 x9 B# s$ e
}).start();
) D, w: l3 t# z6 \# ?0 | }
' e2 u; _4 m& H7 ]1 E* o9 ^6 ?}% J2 ]0 Y5 m8 N1 X* z B+ E+ Q
<receiver android:name=".receive.BootBroadcastReceiver">
9 B# Y. ^% ]: P5 D <intent-filter>
) N. Y" }4 }, q( D0 {+ S <action android:name="android.intent.action.BOOT_COMPLETED" />2 c: Z* s) j4 X' c. R6 J
" h2 m4 g3 m F" m8 h5 j. C <category android:name="android.intent.category.LAUNCHER" />7 Z$ G5 u$ K' X6 Y+ n% z! O$ d
</intent-filter>- c& K |' p- {5 e3 K
</receiver> |
|