Quellcode durchsuchen

去掉桌面应用设置,改成监听开机广播自启动

weizhengliang vor 3 Jahren
Ursprung
Commit
4174286710

+ 12 - 4
nursehome/src/main/AndroidManifest.xml

@@ -83,16 +83,15 @@
         android:label="@string/app_name"
         android:label="@string/app_name"
         android:supportsRtl="true">
         android:supportsRtl="true">
         <activity android:name=".activity.NurseHomeActivity"
         <activity android:name=".activity.NurseHomeActivity"
-            android:screenOrientation="landscape"
-            android:launchMode="singleInstance">
+            android:screenOrientation="landscape">
             <intent-filter>
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
                 <action android:name="android.intent.action.MAIN"/>
 
 
                 <category android:name="android.intent.category.LAUNCHER"/>
                 <category android:name="android.intent.category.LAUNCHER"/>
 
 
                 <!-- 设置成桌面模式 -->
                 <!-- 设置成桌面模式 -->
-                <category android:name="android.intent.category.HOME" />
-                <category android:name="android.intent.category.DEFAULT" />
+<!--                <category android:name="android.intent.category.HOME" />
+                <category android:name="android.intent.category.DEFAULT" />-->
             </intent-filter>
             </intent-filter>
         </activity>
         </activity>
 
 
@@ -101,6 +100,15 @@
             android:launchMode="singleTask"
             android:launchMode="singleTask"
             android:excludeFromRecents="true"/>
             android:excludeFromRecents="true"/>
 
 
+        <receiver
+            android:name=".receiver.WdBootReceiver"
+            android:enabled="true"
+            android:exported="true">
+            <intent-filter android:priority="1000">
+                <action android:name="android.intent.action.BOOT_COMPLETED"/>
+            </intent-filter>
+        </receiver>
+
         <!--<service android:name=".service.APPService"
         <!--<service android:name=".service.APPService"
             android:process=":myService"/>-->
             android:process=":myService"/>-->
 
 

+ 21 - 0
nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/receiver/WdBootReceiver.java

@@ -0,0 +1,21 @@
+package com.wdkl.ncs.android.component.nursehome.receiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import com.wdkl.ncs.android.component.nursehome.activity.NurseHomeActivity;
+
+public class WdBootReceiver extends BroadcastReceiver {
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
+            Log.d("wdBoot", "收到开机广播,启动app");
+            Intent startIntent= new Intent(context, NurseHomeActivity.class);
+            startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            context.startActivity(startIntent);
+        }
+    }
+}