CONMISANMA的正確答案——使用Cordova開發android桌面程序(launcher)

部分內容轉載至:android手把手教你開發launcher(一)(AndroidStudio版)


測試系統:DEEPIN LINUX 15.6

測試軟件:ANDROID STUDIO 3.1.3  &  Cordova 8.0.0

測試機器:i6200掃描槍


1、創建應用:

cordova create hello com.example.hello HelloWorld


2、添加安卓平臺:

cordova platform add android --save


3、打開ANDROID STUDIO,選擇創建的“hello”文件夾,選中文件夾中的../hello/platforms/android,點擊確認


4、等待項目build完畢(進度條走完了還要再等十幾秒),雙擊項目的app/manifests/AndroidManifest.xml


5、內容如下:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true"
          android:versionCode="10000"
          android:versionName="1.0.0"
          package="com.example.hello"
          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" />
    <application android:hardwareAccelerated="true"
                 android:icon="@mipmap/icon"
                 android:label="@string/app_name"
                 android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
                  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">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
</manifest>

6、添加兩行內容至<intent-filter>

<category android:name="android.intent.category.HOME"    />
<category android:name="android.intent.category.DEFAULT" />
7、編譯運行即可把你的應用變成桌面應用


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章