update:2020.05.22
fix:toast显示问题,唤醒服务问题 add:
This commit is contained in:
@@ -52,7 +52,7 @@ public class InstallResultReceiver extends BroadcastReceiver {
|
||||
// Log.e("fht", SESSION_ID);
|
||||
// Log.e("fht", LEGACY_STATUS);
|
||||
// Log.e("fht", STATUS_MESSAGE);
|
||||
if (STATUS_MESSAGE.equals("INSTALL_SUCCEEDED")) {
|
||||
if (STATUS_MESSAGE != null && STATUS_MESSAGE.equals("INSTALL_SUCCEEDED")) {
|
||||
ToastUtil.show(PACKAGE_NAME + "安装成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -42,17 +43,21 @@ import rx.schedulers.Schedulers;
|
||||
|
||||
public class SaveListUtils {
|
||||
private static List<String> downLoadList = new ArrayList<>();
|
||||
private static List<String> forceList = new ArrayList<>();
|
||||
|
||||
public static List<String> getList() {
|
||||
String data = SPStaticUtils.getString(CommonDatas.FORCE_INSTALL);
|
||||
Log.e("mjshenglistdata", data);
|
||||
|
||||
Gson gson = new Gson();
|
||||
Type listType = new TypeToken<List<String>>() {
|
||||
}.getType();
|
||||
List<String> list = gson.fromJson(data, listType);
|
||||
|
||||
// Log.e("mjshenglist1", list.toString());
|
||||
if (list != null && list.size() > 0) {
|
||||
Log.e("fht", "getList:" + list.toString());
|
||||
} else {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -69,6 +74,54 @@ public class SaveListUtils {
|
||||
String gsonData = gson.toJson(list);
|
||||
SPStaticUtils.put(CommonDatas.FORCE_INSTALL, gsonData);
|
||||
}
|
||||
Log.e("fht", "addToList:" + list.toString());
|
||||
}
|
||||
|
||||
public static void setList(List<String> strings) {
|
||||
forceList.clear();
|
||||
forceList = strings;
|
||||
Gson gson = new Gson();
|
||||
String gsonData = gson.toJson(forceList);
|
||||
SPStaticUtils.put(CommonDatas.FORCE_INSTALL, gsonData);
|
||||
Log.e("fht", "setList:" + forceList.toString());
|
||||
|
||||
}
|
||||
|
||||
public static void addList(String s) {
|
||||
if (!forceList.contains(s)) {
|
||||
forceList.add(s);
|
||||
}
|
||||
Log.e("fht", "addList:" + forceList.toString());
|
||||
|
||||
}
|
||||
|
||||
public static void setList() {
|
||||
Gson gson = new Gson();
|
||||
String gsonData = gson.toJson(forceList);
|
||||
SPStaticUtils.put(CommonDatas.FORCE_INSTALL, gsonData);
|
||||
}
|
||||
|
||||
|
||||
public static List<String> getlist() {
|
||||
return forceList;
|
||||
}
|
||||
|
||||
|
||||
public static void sendForceAPP(Context context) {
|
||||
String txt = "";
|
||||
for (String s : forceList) {
|
||||
txt += s + ",";
|
||||
}
|
||||
if (txt.length() > 0) {
|
||||
|
||||
txt = txt.substring(0, txt.length() - 1);
|
||||
boolean qch_force_app = Settings.System.putString(context.getContentResolver(), "qch_force_app", txt);
|
||||
Log.e("fht", "qch_force_app:" + qch_force_app + ":" + txt);
|
||||
} else {
|
||||
boolean qch_force_app = Settings.System.putString(context.getContentResolver(), "qch_force_app", "invalid");
|
||||
Log.e("fht", "qch_force_app:" + qch_force_app + ":" + txt);
|
||||
}
|
||||
setList();
|
||||
}
|
||||
|
||||
public static List<String> getDownLoadList() {
|
||||
@@ -79,7 +132,7 @@ public class SaveListUtils {
|
||||
public static void addDownLoadList(String packageName) {
|
||||
if (downLoadList == null) {
|
||||
downLoadList = new ArrayList<>();
|
||||
downLoadList.add(packageName);
|
||||
downLoadList.add(packageName);
|
||||
} else {
|
||||
if (!downLoadList.contains(packageName)) {
|
||||
downLoadList.add(packageName);
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.mjsheng.myappstore.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mjsheng.myappstore.BuildConfig;
|
||||
@@ -14,13 +16,15 @@ import com.mjsheng.myappstore.BuildConfig;
|
||||
*/
|
||||
|
||||
public class ToastUtil {
|
||||
static Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
static Toast toast;
|
||||
private static Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
private static Toast toast;
|
||||
private static Context mContext;
|
||||
|
||||
@SuppressLint("ShowToast")
|
||||
public static void init(Context context) {
|
||||
toast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
|
||||
debugToast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
|
||||
mContext = context;
|
||||
toast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
|
||||
debugToast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
|
||||
|
||||
}
|
||||
|
||||
@@ -28,12 +32,38 @@ public class ToastUtil {
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (toast != null) {
|
||||
toast.setText(msg);
|
||||
toast.show();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
showToast(mContext, msg, Toast.LENGTH_LONG);
|
||||
Log.e("fht", "LENGTH_LONG");
|
||||
|
||||
} else {
|
||||
if (toast != null) {
|
||||
toast.setText(msg);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private static Toast mToast = null;
|
||||
|
||||
//android 8.0以后限制
|
||||
//https://www.jianshu.com/p/d9813ad03d59
|
||||
//https://www.jianshu.com/p/050ce052b873
|
||||
public static void showToast(Context context, String text, int duration) {
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.P) {
|
||||
Toast.makeText(context, text, duration).show();
|
||||
} else {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, text, duration);
|
||||
} else {
|
||||
mToast.setText(text);
|
||||
mToast.setDuration(duration);
|
||||
}
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
// public static void showInCenter(String msg) {
|
||||
|
||||
Reference in New Issue
Block a user