限制单例运行

serial
BlueMatthew 1 year ago
parent 2a4fd7aa37
commit 086f535b54

@ -152,10 +152,10 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true"
android:launchMode="singleTop"
android:screenOrientation="landscape"> 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" />
</intent-filter> </intent-filter>
</activity> </activity>

@ -0,0 +1,67 @@
project.archivesBaseName = "XXXApp"
static def releaseTime() {
return new Date().format("HHmmss")//yyyyMMdd_HHmmss
}
android.applicationVariants.all { variant ->
variant.outputs.all {
if (outputFileName.endsWith('.apk')) {
//使apk
// outputFileName = "${project.archivesBaseName}_v${variant.productFlavors[0].versionName}_${variant.productFlavors[0].versionCode}_${variant.productFlavors[0].name}_${releaseTime()}_${variant.buildType.name}.apk"
outputFileName = "${project.archivesBaseName}_${versionCode}_v${versionName}_${releaseTime()}_${name}.apk"
}
}
//output
File desFilePath = new File("${rootDir}/output")
//output
delete desFilePath
//API 'variant.getAssemble()' is obsolete and has been replaced with 'variant.getAssembleProvider()'.
//It will be removed in version 7.0 of the Android Gradle plugin.
//apk
// variant.assemble.doLast {
// variant.outputs.all {
// try {
// //
// if (!desFilePath.exists()) {
// desFilePath.mkdir()
// }
// //apk output
// copy {
// from outputFile
// into desFilePath
// include '**/*.apk'
// }
// } catch (Exception e) {
// e.printStackTrace()
// }
// }
// }
//used variant.getAssembleProvider().
//(variant.assembleProvider.configure|variant.assembleProvider.get.doLast)
//https://stackoverflow.com/questions/54193510/while-android-studio-updated-to-v3-3-getting-api-variant-getassemble-is-obso
variant.assembleProvider.configure {
it.doLast {
variant.outputs.all {
try {
//
if (!desFilePath.exists()) {
desFilePath.mkdir()
}
//apk output
copy {
from outputFile
into desFilePath
include '**/*.apk'
}
} catch (Exception e) {
e.printStackTrace()
}
}
}
}
}
Loading…
Cancel
Save