Bläddra i källkod

1.app提示语设置为sting资源

20241218TB223FC(测试jar包)
wangwanlei 9 månader sedan
förälder
incheckning
a58a83ba38

+ 15
- 6
app/src/main/java/com/xhly/manageapp/AppAdapter.kt Visa fil

@@ -1,7 +1,6 @@
1 1
 package com.xhly.manageapp
2 2
 
3 3
 import DownLoadUtils
4
-import android.content.ComponentName
5 4
 import android.content.Context
6 5
 import android.content.Intent
7 6
 import android.provider.Settings
@@ -66,27 +65,35 @@ class AppAdapter(var context: Context, var data: ArrayList<AppInfo>) :
66 65
                     lastTimeLong=System.currentTimeMillis()
67 66
                     UIEvent(Const.CODE2004.toString()).post()
68 67
                 }else{
69
-                    Toaster.show("请求过于频繁,请稍等")
68
+                    Toaster.show(context.getString(R.string.strategyupdatetips))
70 69
                 }
71 70
             }else if (appInfo.packageName.equals(Const.WIFISEETTINGPKG)){
72 71
                 context.startActivity(Intent(Settings.ACTION_WIFI_SETTINGS))
73 72
             }else if (appInfo.packageName.equals(Const.STOREAPPPKG)){
74 73
                 //跳转应用商店
75 74
                 if (!AppUtils.isAppInstalled(context,appInfo.packageName)){
76
-                    Toaster.show("应用正在安装,请稍后")
75
+                    Toaster.show(context.getString(R.string.startapptips))
77 76
                     return@setOnClickListener
78 77
                 }
79 78
                 var destroyFlag=false
80 79
                 try {
81
-                    val launchIntent = Intent()
80
+                   /* val launchIntent = Intent()
82 81
                     launchIntent.setComponent(
83 82
                         ComponentName(
84 83
                             Const.STOREAPPPKG,
85 84
                             Const.STOREAPPPKG+".MainActivity"
86 85
                         )
87 86
                     )
88
-                    context.startActivity(launchIntent)
89
-                    destroyFlag=true
87
+                    context.startActivity(launchIntent)*/
88
+                    val intent: Intent? =
89
+                        context.getPackageManager().getLaunchIntentForPackage(Const.STOREAPPPKG)
90
+                    if (intent != null) {
91
+                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
92
+                        context.startActivity(intent)
93
+                        destroyFlag=true
94
+                    }else{
95
+                        destroyFlag=false
96
+                    }
90 97
                 }catch (e:Exception){
91 98
                     destroyFlag=false
92 99
                     LogShow("失败原因"+e.toString())
@@ -94,6 +101,8 @@ class AppAdapter(var context: Context, var data: ArrayList<AppInfo>) :
94 101
                     if (destroyFlag){
95 102
                         DownLoadUtils.destroyDownLoad()
96 103
                         InstallUtils.destroyInstallUtils()
104
+                    }else{
105
+                        Toaster.show(context.getString(R.string.startapptips))
97 106
                     }
98 107
                 }
99 108
             } else{

+ 2
- 0
app/src/main/res/values/strings.xml Visa fil

@@ -45,4 +45,6 @@
45 45
     <string name="updatestrategy">更新策略</string>
46 46
     <string name="updatetips">策略更新完成</string>
47 47
     <string name="checkcode">密码校验</string>
48
+    <string name="startapptips">应用正在安装,请稍后</string>
49
+    <string name="strategyupdatetips">请求过于频繁,请稍等</string>
48 50
 </resources>

Laddar…
Avbryt
Spara