-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
实现应用内更新功能,包括检查更新、显示更新信息和强制更新逻辑。添加了必要的UI提示,以增强用户体验。同时,设置了proguard规则、定义了应用签名信息,并规范了构建配置。此次更新还包含了测试代码的添加和资源文件的更新。```
- Loading branch information
0 parents
commit 2e144e3
Showing
53 changed files
with
1,345 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# 应用内更新 | ||
|
||
本项目借助蒲公英分发相关api,封装了一个简单的应用内更新功能,无需让后台开发相关更新接口即可实现应用内更新功能,使用简单,仅需几行代码,即可实现。 | ||
|
||
|
||
https://www.pgyer.com/doc/view/api#appUpdate | ||
|
||
#### 作者的其他项目 | ||
- [友你](https://sj.qq.com/appdetail/com.youni.mobile) 友你是一款征婚交友APP,在这里,你可以把你的真实信息登记下来,系统会根据您的信息,为您匹配最合适的TA,友你集交友、恋爱于一身,通过在线匹配,解决陌生人社交破冰难题,打造更真实的恋爱社区。 | ||
- [友圈](https://sj.qq.com/appdetail/com.youquan.mobile) 友圈是一款基于圈子交友的社区交友软件,被广大年轻人所青睐,在这里有着你所感兴趣的方方面面,应用内拥有生活、游戏、元宇宙、二次元、娱乐、绘画、设计、文学、时尚等多个领域,上千种兴趣标签,给你丰富的吐槽空间,在这里你可以吐槽生活中的不愉快,也可以针对时事新闻发表自己的观点。 | ||
- [一木林(已开源)](https://sj.qq.com/appdetail/com.yimulin.mobile) [开源版本](https://github.com/dxmwl/Yimulin)这是一款多功能工具类应用,因为 一木林 体积十分小巧而功能却又非常的完善强大,使它风评很高。 | ||
- [天天省钱(计划开源)](https://sj.qq.com/appdetail/com.ttsq.mobile) 优惠券,优惠劵,优惠,淘宝优惠券,返利优惠券,返利网,拼多多优惠券,饿了么红包,外卖红包优惠劵,淘趣购物返利优惠券,省钱就选天天省钱。 专注于淘宝优惠券的购物APP,超级折扣超级优惠,省钱20%以上。 | ||
- [青果短剧(已开源)](https://github.com/dxmwl/qg_android) 这是一个免费观看短剧、短视频的开源项目,供大家免费学习使用 | ||
- [小蜜蜂传包(已开源)](https://github.com/dxmwl/new_bee_upload_app) 一键上传Apk到多个应用市场,开源,免费 | ||
- [应用内更新(已开源)](https://github.com/dxmwl/update_app_online) 几行代码实现应用内更新功能 | ||
|
||
#### 联系开发者 | ||
欢迎加入开发者交流群,可加我微信:dxmcpjl,加好友备注"应用内更新",否则可能无法添加好友,如果本项目对您的业务有所帮助,欢迎对本项目进行资助,我将对本项目进行持续维护 | ||
|
||
| ![输入图片说明](pictures/963a20fad5b96ec502acdad875776ac.jpg) | ![输入图片说明](pictures/c703e10d18655356cf05d4ccb7ec34f.jpg) | ![输入图片说明](pictures/dd1fae18c9c1bf30d50070e951dfe39.jpg) | | ||
|---------------------------------------------------------|---------------------------------------------------|---| | ||
|
||
## 写在最后 | ||
撸码不易,欢迎点赞对我进行鼓励,点赞越多,优化越快 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
plugins { | ||
alias(libs.plugins.android.application) | ||
alias(libs.plugins.jetbrains.kotlin.android) | ||
} | ||
|
||
android { | ||
namespace 'com.clb.update_app_online' | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
applicationId "com.clb.update_app_online" | ||
minSdk 24 | ||
targetSdk 34 | ||
versionCode 2 | ||
versionName "1.1" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
// Apk 签名的那些事:https://www.jianshu.com/p/a1f8e5896aa2 | ||
signingConfigs { | ||
config { | ||
storeFile file(StoreFile) | ||
storePassword StorePassword | ||
keyAlias KeyAlias | ||
keyPassword KeyPassword | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
// 签名信息配置 | ||
signingConfig signingConfigs.config | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation libs.androidx.core.ktx | ||
implementation libs.androidx.appcompat | ||
implementation libs.material | ||
implementation libs.androidx.activity | ||
implementation libs.androidx.constraintlayout | ||
implementation project(':update_app_online') | ||
testImplementation libs.junit | ||
androidTestImplementation libs.androidx.junit | ||
androidTestImplementation libs.androidx.espresso.core | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
StoreFile = AppKey.jks | ||
StorePassword = 111111 | ||
KeyAlias = key0 | ||
KeyPassword = 111111 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"version": 3, | ||
"artifactType": { | ||
"type": "APK", | ||
"kind": "Directory" | ||
}, | ||
"applicationId": "com.clb.update_app_online", | ||
"variantName": "release", | ||
"elements": [ | ||
{ | ||
"type": "SINGLE", | ||
"filters": [], | ||
"attributes": [], | ||
"versionCode": 1, | ||
"versionName": "1.0", | ||
"outputFile": "app-release.apk" | ||
} | ||
], | ||
"elementType": "File", | ||
"baselineProfiles": [ | ||
{ | ||
"minApi": 28, | ||
"maxApi": 30, | ||
"baselineProfiles": [ | ||
"baselineProfiles/1/app-release.dm" | ||
] | ||
}, | ||
{ | ||
"minApi": 31, | ||
"maxApi": 2147483647, | ||
"baselineProfiles": [ | ||
"baselineProfiles/0/app-release.dm" | ||
] | ||
} | ||
], | ||
"minSdkVersionForDexing": 24 | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/com/clb/update_app_online/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.clb.update_app_online | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.clb.update_app_online", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET"/> | ||
|
||
<application | ||
android:name=".MyApp" | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.Update_app_online" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
47 changes: 47 additions & 0 deletions
47
app/src/main/java/com/clb/update_app_online/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.clb.update_app_online | ||
|
||
import android.os.Bundle | ||
import android.util.Log | ||
import android.widget.Button | ||
import android.widget.Toast | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.clb.update_app_online.UpdateChecker.Callback | ||
|
||
class MainActivity : AppCompatActivity() { | ||
private val TAG = "MainActivity" | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
findViewById<Button>(R.id.btn_check_update).setOnClickListener { | ||
UpDateApp.checkUpdate(object : Callback { | ||
override fun result(updateInfo: UpdateChecker.UpdateInfo?) { | ||
//注意这里要在主线程中执行更新UI的操作 | ||
runOnUiThread { | ||
AlertDialog.Builder(this@MainActivity) | ||
.setTitle("版本更新") | ||
.setMessage( | ||
"是否强制更新:${updateInfo?.needForceUpdate}\n" + | ||
"应用安装地址:${updateInfo?.downloadURL}\n" + | ||
"版本号:${updateInfo?.buildVersion}\n" + | ||
"应用更新说明:${updateInfo?.buildUpdateDescription}" | ||
) | ||
.show() | ||
} | ||
} | ||
|
||
override fun error(message: String?) { | ||
Log.e(TAG, "error: $message") | ||
//注意这里要在主线程中执行更新UI的操作 | ||
runOnUiThread { | ||
Toast.makeText(this@MainActivity, "错误信息:${message}", Toast.LENGTH_SHORT) | ||
.show() | ||
} | ||
} | ||
|
||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.clb.update_app_online | ||
|
||
import android.app.Application | ||
|
||
class MyApp: Application() { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
UpDateApp.init("ede71b84c7e1009fe6bdee737c7dfaf4","5885ac48608e2a0470266d3980484746") | ||
} | ||
} |
Oops, something went wrong.