file_paths.xml

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:andro />
</paths>

原:
Uri uri = Uri.fromFile(new File(filename));
Intent localIntent = new Intent(Intent.ACTION_VIEW);
localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
localIntent.setDataAndType(uri, "application/vnd.android.package-archive");
startActivity(localIntent);

修改后:

Intent localIntent = IntentUtils.getInstallAppIntent(new File(filename), true);

localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

startActivity(localIntent);

public static Intent getInstallAppIntent(final File file, final boolean isNewTask) {
if (file == null) return null;
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri data;
String type = "application/vnd.android.package-archive";
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
data = Uri.fromFile(file);
} else {
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
String authority = Utils.getApp().getPackageName() + ".utilcode.provider";
data = FileProvider.getUriForFile(Utils.getApp(), authority, file);
}
intent.setDataAndType(data, type);
return getIntent(intent, isNewTask);
}

7.0 WebView 部分机型打不开 (未尝试)

转:https://blog.csdn.net/u012347067/article/details/70829013
https 请求 webview 有 证书校验

@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
if (error.getPrimaryError() == SslError.SSL_DATE_INVALID
|| error.getPrimaryError() == SslError.SSL_EXPIRED
|| error.getPrimaryError() == SslError.SSL_INVALID
|| error.getPrimaryError() == SslError.SSL_UNTRUSTED) {
handler.proceed();
} else {
handler.cancel();
}
super.onReceivedSslError(view, handler, error);
}
通过重写:
onReceivedSslError 过滤掉 部分错误
SSL_DATE_INVALID 证书的日期是无效的
SSL_EXPIRED 证书已经过期
SSL_INVALID 一个通用的错误发生
SSL_UNTRUSTED 不受信任的证书颁发机构


参考:https://blog.csdn.net/namehybin/article/details/78571964

相关文章:

  • 2021-10-25
  • 2022-12-23
  • 2021-09-17
  • 2021-11-28
  • 2021-05-16
  • 2021-06-20
猜你喜欢
  • 2022-02-16
  • 2021-10-18
  • 2022-02-16
  • 2022-01-19
  • 2022-02-16
  • 2022-02-01
  • 2021-10-07
相关资源
相似解决方案