update:2020.05.23

fix:10.0网络问题,设备号获取问题
add:
This commit is contained in:
2020-05-23 17:49:46 +08:00
parent f037e1cb12
commit 12172e6706
23 changed files with 61 additions and 68 deletions

View File

@@ -156,7 +156,7 @@ public class MainActivity extends AppCompatActivity {
mHits[mHits.length - 1] = SystemClock.uptimeMillis();
if (mHits[0] >= (SystemClock.uptimeMillis() - DURATION)) {
mHits = new long[COUNTS];//重新初始化数组
Toast.makeText(this, "正在检查更新", Toast.LENGTH_SHORT).show();
ToastUtil.show("正在检查更新");
HTTPInterface.checkUpdateByself(handler, this.getPackageName(), String.valueOf(BuildConfig.VERSION_CODE));
}
}
@@ -189,7 +189,7 @@ public class MainActivity extends AppCompatActivity {
public void exit() {
if ((System.currentTimeMillis() - mExitTime) > 2000) {
Toast.makeText(MainActivity.this, "再按一次退出程序", Toast.LENGTH_SHORT).show();
ToastUtil.show("再按一次退出程序");
mExitTime = System.currentTimeMillis();
} else {
finish();

View File

@@ -486,7 +486,9 @@ public class MyApplication extends Application {
ToastUtil.show("设备取消绑定");
dialog.dismiss();
}
}).show();
});
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
dialog.show();
// AlertDialog.Builder builder = new AlertDialog.Builder(this)
// .setTitle("设备绑定")
// .setIcon(R.mipmap.ic_launcher)

View File

@@ -76,7 +76,7 @@ public class ApkUtils {
Intent intent = context.getPackageManager().getLaunchIntentForPackage((String) view.getTag(R.string.download_btn_had));
context.startActivity(intent);
} catch (Exception e) {
Toast.makeText(context, R.string.open_app_fail, Toast.LENGTH_LONG).show();
ToastUtil.show(String.valueOf(R.string.open_app_fail));
}
return;
}
@@ -275,12 +275,12 @@ public class ApkUtils {
public void onNext(Integer value) {
if (value == 2) {
//安装成功
Utils.showToast(context, "安装成功");
ToastUtil.show("安装成功");
Log.e("fanhuitong", "-----------安装成功-----------");
} else {
//安装错误
Log.e("fanhuitong", "------------安装错误-----------");
Utils.showToast(context, "安装失败");
ToastUtil.show("安装失败");
}
}
@@ -336,6 +336,7 @@ public class ApkUtils {
e.printStackTrace();
}
}
public static boolean installApp(Context context, String apkPath) {
ToastUtil.show("正在安装应用...");
Process process = null;
@@ -464,6 +465,7 @@ public class ApkUtils {
}
return name;
}
public static void installApk(Activity activity, File newApkFile) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
@@ -479,7 +481,8 @@ public class ApkUtils {
intent.setDataAndType(uri, type);
activity.startActivity(intent);
}
public static void installApk(Context context, File newApkFile) {
public static void installApk(Context context, File newApkFile) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

View File

@@ -49,13 +49,13 @@ public class ToastUtil {
static Toast debugToast;
public static void debugShow(final String msg) {
mainHandler.post(new Runnable() {
debugHandler.post(new Runnable() {
@Override
public void run() {
if (BuildConfig.LOG_DEBUG) {
if (toast != null) {
toast.setText(msg);
toast.show();
if (debugToast != null) {
debugToast.setText(msg);
debugToast.show();
}
}
}

View File

@@ -48,6 +48,7 @@ import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
import java.lang.reflect.Method;
import java.net.NetworkInterface;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -408,14 +409,14 @@ public class Utils {
public static void unInstallAPP(Context context, String packageName) {
if (!TextUtils.isEmpty(packageName) && !AppsManagerUtils.isSystemApp(context, packageName)) {
if (AppsManagerUtils.isSystemApp(context, packageName)) {
Toast.makeText(MyApplication.getAppContext(), "系统应用无法卸载!", Toast.LENGTH_SHORT).show();
ToastUtil.show("系统应用无法卸载!");
} else {
Uri packageURI = Uri.parse("package:" + packageName);
Intent intent = new Intent(Intent.ACTION_DELETE, packageURI);
context.startActivity(intent);
}
} else {
Toast.makeText(MyApplication.getAppContext(), "系统应用无法卸载!", Toast.LENGTH_SHORT).show();
ToastUtil.show("系统应用无法卸载!");
}
}
@@ -688,11 +689,24 @@ public class Utils {
*
* @return
*/
@SuppressLint({"MissingPermission", "NewApi"})
public static String getSerial() {
return Build.SERIAL;
// return "QNS3AI000111";
// return "QNW8WJ900002";
String serial = "unknow";
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+
serial = Build.getSerial();
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {//8.0+
serial = Build.SERIAL;
} else {//8.0-
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class);
serial = (String) get.invoke(c, "ro.serialno");
}
} catch (Exception e) {
e.printStackTrace();
Log.e("e", "读取设备序列号异常:" + e.toString());
}
return serial;
}
public static final long A_GB = 1073741824;
@@ -860,5 +874,4 @@ public class Utils {
}
}

View File

@@ -67,7 +67,6 @@ public class CustomDialog extends Dialog {
setContentView(R.layout.custom_dialog);
//按空白处不能取消动画
setCanceledOnTouchOutside(false);
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
//初始化界面控件
initView();
//初始化界面数据