mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-09-06 09:53:43 +00:00
Update UpdateManager.kt
This commit is contained in:
parent
c42b4a59de
commit
260f9ee848
|
@ -9,7 +9,7 @@ import android.util.Log
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.ResponseBody
|
import okhttp3.ResponseBody // 引入 ResponseBody
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
class UpdateManager(private val context: Context) {
|
class UpdateManager(private val context: Context) {
|
||||||
|
@ -18,7 +18,7 @@ class UpdateManager(private val context: Context) {
|
||||||
|
|
||||||
fun checkForUpdates() {
|
fun checkForUpdates() {
|
||||||
val currentVersion = BuildConfig.VERSION_NAME // 当前应用版本
|
val currentVersion = BuildConfig.VERSION_NAME // 当前应用版本
|
||||||
val updateUrl = "http://mkoc.cn/aip/version.php" // 用于检查更新的服务器端点
|
val updateUrl = "https://your-server.com/check_update.php" // 用于检查更新的服务器端点
|
||||||
|
|
||||||
// 异步任务执行更新检查
|
// 异步任务执行更新检查
|
||||||
object : AsyncTask<Void, Void, String>() {
|
object : AsyncTask<Void, Void, String>() {
|
||||||
|
@ -30,16 +30,15 @@ class UpdateManager(private val context: Context) {
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val response: Response = client.newCall(request).execute()
|
val response: Response = client.newCall(request).execute()
|
||||||
if (response.isSuccessful) {
|
|
||||||
val responseBody: ResponseBody? = response.body()
|
val responseBody: ResponseBody? = response.body() // 存储在变量中
|
||||||
if (responseBody != null) {
|
val responseCode: Int = response.code() // 存储在变量中
|
||||||
val result = responseBody.string()
|
|
||||||
return result
|
if (responseBody != null) {
|
||||||
} else {
|
val result = responseBody.string()
|
||||||
Log.e(TAG, "Response body is empty")
|
return result
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Unsuccessful response: ${response.code()}")
|
Log.e(TAG, "Response body is empty")
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "Error checking for updates: ${e.message}")
|
Log.e(TAG, "Error checking for updates: ${e.message}")
|
||||||
|
|
Loading…
Reference in a new issue