platforms/android/android.iml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
platforms/android/app/src/main/AndroidManifest.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
platforms/android/app/src/main/java/com/receivers/MyBootReceiver.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
platforms/android/android.iml
@@ -8,13 +8,13 @@ </configuration> </facet> </component> <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true"> <component name="NewModuleRootManager" inherit-compiler-output="true"> <exclude-output /> <content url="file://$MODULE_DIR$"> <excludeFolder url="file://$MODULE_DIR$/.gradle" /> <excludeFolder url="file://$MODULE_DIR$/build" /> </content> <orderEntry type="inheritedJdk" /> <orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" /> <orderEntry type="sourceFolder" forTests="false" /> </component> </module> platforms/android/app/src/main/AndroidManifest.xml
@@ -2,6 +2,10 @@ <manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="io.cordova.hellocordova" xmlns:android="http://schemas.android.com/apk/res/android"> <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /> <uses-permission android:name="android.permission.INTERNET" /> <!-- 程序自启动权限 --> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true"> <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize"> <intent-filter android:label="@string/launcher_name"> @@ -9,5 +13,15 @@ <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- 程序自启动广播 --> <receiver android:name="com.receivers.MyBootReceiver" android:enabled="true" android:exported="true"> <intent-filter android:priority="1000"> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> </application> </manifest> platforms/android/app/src/main/java/com/receivers/MyBootReceiver.java
New file @@ -0,0 +1,22 @@ package com.receivers; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import io.cordova.hellocordova.MainActivity; /** * 开机自启广播接收器 */ public class MyBootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) { Intent i = new Intent(context, MainActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } } }