Browse Source

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

20241218TB223FC(测试jar包)
wangwanlei 9 months ago
parent
commit
a58a83ba38

+ 15
- 6
app/src/main/java/com/xhly/manageapp/AppAdapter.kt View File

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

+ 2
- 0
app/src/main/res/values/strings.xml View File

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

Loading…
Cancel
Save