update sdk of xiaomi
This commit is contained in:
parent
1bfc54167f
commit
06dcbbb6f6
@ -6,8 +6,8 @@ android {
|
||||
applicationId "com.hnjc.wjtx.mi"
|
||||
minSdkVersion 18
|
||||
targetSdkVersion 28
|
||||
versionCode 3
|
||||
versionName "1.0.3"
|
||||
versionCode 5
|
||||
versionName "1.0.5"
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a'
|
||||
}
|
||||
|
@ -2,13 +2,17 @@ package com.hnjc.wjtx;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -18,6 +22,7 @@ import com.hnjc.wjtx.net.WebApi;
|
||||
import com.hnjc.wjtx.util.AssetsUtil;
|
||||
import com.hnjc.wjtx.util.StringUtil;
|
||||
import com.hnjc.wjtx.util.UnzipRunnable;
|
||||
import com.xiaomi.gamecenter.sdk.MiCommplatform;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@ -47,6 +52,7 @@ public class LaunchActivity extends Activity {
|
||||
private TaskInfo info;//任务信息
|
||||
private DownloadRunnable runnable;//下载任务
|
||||
private UnzipRunnable unzipRunnable; // 解压任务
|
||||
private boolean alterShowed;
|
||||
|
||||
private static final String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
@ -88,11 +94,15 @@ public class LaunchActivity extends Activity {
|
||||
webApi = new WebApi(this);
|
||||
localVersion = this.getString(R.string.local_version);
|
||||
|
||||
runOnUiThread(this::alertUserAgreement);
|
||||
}
|
||||
|
||||
private void checkVersion() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
int check = checkSelfPermission(permissions[0]);
|
||||
if (check != PackageManager.PERMISSION_GRANTED) {
|
||||
requestPermissions(permissions, 111);
|
||||
return;
|
||||
}
|
||||
}
|
||||
compareVersions();
|
||||
@ -278,4 +288,62 @@ public class LaunchActivity extends Activity {
|
||||
overridePendingTransition(0, 0);
|
||||
}
|
||||
|
||||
private void alertUserAgreement() {
|
||||
SharedPreferences sp = getSharedPreferences("userAgreementResult", 0);
|
||||
boolean agreed = sp.getBoolean("userAgreementResult", false);
|
||||
if (agreed) {
|
||||
//申请SDK所需权限,会弹出权限说明弹框,并且用户拒绝权限申请不会对SDK功能造成影响,48小时内不会再次弹出
|
||||
// MiCommplatform.getInstance().requestPermission(this);
|
||||
//用户已经同意过隐私协议,直接通过
|
||||
MiCommplatform.getInstance().onUserAgreed(this);
|
||||
checkVersion();
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
WebView mwebView = new WebView(this);
|
||||
this.alterShowed = false;
|
||||
mwebView.loadUrl("https://privacy2.kingsome.cn/");
|
||||
mwebView.setWebViewClient( new WebViewClient() {
|
||||
//设置结束加载函数
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
if (!alterShowed) {
|
||||
alterShowed = true;
|
||||
builder.show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
builder.setPositiveButton( "取消", null );
|
||||
builder.setView( mwebView );
|
||||
// builder.setTitle("隐私协议");
|
||||
builder.setPositiveButton("同意", (dialog, which) -> {
|
||||
//申请SDK所需权限,会弹出权限说明弹框,并且用户拒绝权限申请不会对SDK功能造成影响,48小时内不会再次弹出
|
||||
// MiCommplatform.getInstance().requestPermission(this);
|
||||
//用户同意隐私协议,通过
|
||||
MiCommplatform.getInstance().onUserAgreed(this);
|
||||
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putBoolean("userAgreementResult", true);
|
||||
editor.apply();
|
||||
dialog.dismiss();
|
||||
checkVersion();
|
||||
});
|
||||
builder.setNegativeButton("拒绝", (dialog, which) -> {
|
||||
//用户不同意隐私协议,不通过,Demo在此处退出游戏,接入方可按自己要求处理,但不能调用MiCommplatform.getInstance().onUserAgreed(this);
|
||||
dialog.dismiss();
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
||||
int[] grantResults) {
|
||||
switch (requestCode) {
|
||||
case 111:
|
||||
compareVersions();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,6 +73,8 @@ public class MainActivity extends Activity implements OnLoginProcessListener, On
|
||||
}
|
||||
setContentView(nativeAndroid.getRootFrameLayout());
|
||||
rootLayout = nativeAndroid.getRootFrameLayout();
|
||||
//申请SDK所需权限,会弹出权限说明弹框,并且用户拒绝权限申请不会对SDK功能造成影响,48小时内不会再次弹出
|
||||
MiCommplatform.getInstance().requestPermission(this);
|
||||
showLoadingView();
|
||||
vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user