修改百度icon, 完善百度相关必接的玩意
This commit is contained in:
parent
0c6d26b3d0
commit
048609ce9c
@ -2,19 +2,15 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hnjc.wjtx">
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
android:largeScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:smallScreens="true" />
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<!-- ↓↓↓ SDK ↓↓↓ -->
|
||||
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||
@ -27,9 +23,15 @@
|
||||
<permission android:name="baidu.push.permission.WRITE_PUSHINFOPROVIDER.com.hnjc.wjtx.g.baidu"
|
||||
android:protectionLevel="normal" />
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
android:largeScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:smallScreens="true" />
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:icon="@drawable/icon"
|
||||
android:name=".JCApplication"
|
||||
android:label="@string/app_name"
|
||||
android:usesCleartextTraffic="true"
|
||||
|
@ -34,7 +34,7 @@ public class MainActivity extends BaseActivity {
|
||||
private FrameLayout rootLayout = null;
|
||||
private Vibrator vibrator;
|
||||
private String uid;
|
||||
|
||||
private String token;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -77,6 +77,8 @@ public class MainActivity extends BaseActivity {
|
||||
BDGameSDK.showFloatView(this); // 【选接,建议接】显示悬浮窗
|
||||
|
||||
setAntiAddictionListener(); // todo:【必接】防沉迷相关设置
|
||||
|
||||
BDGameSDK.queryGameUpdateInfo(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -247,7 +249,7 @@ public class MainActivity extends BaseActivity {
|
||||
*/
|
||||
nativeAndroid.setExternalInterface("reportRoleInfo", message -> {
|
||||
Log.i(TAG, "Get reportRoleInfo: " + message);
|
||||
//TODO:
|
||||
//
|
||||
// 上报玩家游戏角色信息Json串,格式为:{
|
||||
// "nick":"昵称",
|
||||
// "role":"角色名",
|
||||
@ -260,7 +262,7 @@ public class MainActivity extends BaseActivity {
|
||||
try {
|
||||
JSONObject obj = new JSONObject(message);
|
||||
data.put("nick", obj.getString("userRoleName"));
|
||||
data.put("role", "1");
|
||||
data.put("role", obj.getString("userRoleName"));
|
||||
data.put("region", obj.getString("serverName"));
|
||||
data.put("server", obj.getString("serverId"));
|
||||
data.put("level", obj.getInt("userRoleLevel"));
|
||||
@ -316,25 +318,30 @@ public class MainActivity extends BaseActivity {
|
||||
(resultCode, resultDesc, extraData) -> {
|
||||
switch (resultCode) {
|
||||
case ResultCode.LOGIN_SUCCESS:
|
||||
// TODO 登录成功,不管之前是什么登录状态,游戏内部都要切换成新的用户
|
||||
// 登录成功,不管之前是什么登录状态,游戏内部都要切换成新的用户
|
||||
uid = BDGameSDK.getLoginUid();
|
||||
token = BDGameSDK.getLoginAccessToken();
|
||||
nativeAndroid.callExternalInterface("changeAccount", "");
|
||||
// 切换账号成功后必须更新uid给调用支付api使用
|
||||
// Toast.makeText(getApplicationContext(),
|
||||
// "登录成功",
|
||||
// Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case ResultCode.LOGIN_FAIL:
|
||||
// TODO
|
||||
// 登录失败,游戏内部之前如果是已经登录的,要清除自己记录的登录状态,设置成未登录。如果之前未登录,不用处理。
|
||||
Toast.makeText(getApplicationContext(), "登录失败", Toast.LENGTH_LONG).show();
|
||||
if (null != uid && null != token) {
|
||||
uid = null;
|
||||
token = null;
|
||||
nativeAndroid.callExternalInterface("loginOut", "");
|
||||
}
|
||||
break;
|
||||
case ResultCode.LOGIN_CANCEL:
|
||||
// TODO 取消,操作前后的登录状态没变化
|
||||
// 取消,操作前后的登录状态没变化
|
||||
Toast.makeText(getApplicationContext(), "登录取消",
|
||||
Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
default:
|
||||
// TODO
|
||||
// 此时当登录失败处理,参照ResultCode.LOGIN_FAIL(正常情况下不会到这个步骤,除非SDK内部异常)
|
||||
Toast.makeText(getApplicationContext(), "登录失败",
|
||||
Toast.LENGTH_LONG).show();
|
||||
@ -351,7 +358,8 @@ public class MainActivity extends BaseActivity {
|
||||
BDGameSDK.setSessionInvalidListener((resultCode, resultDesc, extraData) -> {
|
||||
if (resultCode == ResultCode.SESSION_INVALID) {
|
||||
// 会话失效,开发者需要重新登录或者重启游戏
|
||||
login();
|
||||
// login();
|
||||
nativeAndroid.callExternalInterface("loginOut", "");
|
||||
}
|
||||
|
||||
});
|
||||
@ -361,6 +369,17 @@ public class MainActivity extends BaseActivity {
|
||||
* @Description: 登录
|
||||
*/
|
||||
private void login() {
|
||||
if (null != uid && null != token) {
|
||||
JSONObject obj = new JSONObject();
|
||||
try {
|
||||
obj.put("openid", uid);
|
||||
obj.put("token", token);
|
||||
nativeAndroid.callExternalInterface("sendUidToJS", obj.toString());
|
||||
return;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
BDGameSDK.login((resultCode, resultDesc, extraData) -> {
|
||||
Log.d("login", "this resultCode is " + resultCode);
|
||||
switch (resultCode) {
|
||||
@ -373,10 +392,11 @@ public class MainActivity extends BaseActivity {
|
||||
Log.i("login", BDGameSDK.getLoginAccessToken());
|
||||
Log.i("login", "login sucess");
|
||||
uid = BDGameSDK.getLoginUid();
|
||||
token = BDGameSDK.getLoginAccessToken();
|
||||
JSONObject obj = new JSONObject();
|
||||
try {
|
||||
obj.put("openid", uid);
|
||||
obj.put("token", BDGameSDK.getLoginAccessToken());
|
||||
obj.put("token", token);
|
||||
// 如果其他登陆过程中的错误, 则传入一个大于0的errorcode
|
||||
nativeAndroid.callExternalInterface("sendUidToJS", obj.toString());
|
||||
} catch (JSONException e) {
|
||||
@ -403,7 +423,7 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
// [必接]设置防沉迷系统回调,如果用户在线时长累计超过规定值,会触发该回调
|
||||
BDGameSDK.setAntiAddictionListener((resultCode, resultDesc, extraData) -> {
|
||||
//TODO: 默认直接弹出游玩超时警告弹窗退出游戏,厂商也可以根据自己需要进行自己的防沉迷设计
|
||||
//默认直接弹出游玩超时警告弹窗退出游戏,厂商也可以根据自己需要进行自己的防沉迷设计
|
||||
BDGameSDK.forceCloseDialog(MainActivity.this);
|
||||
});
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 351 KiB |
Loading…
x
Reference in New Issue
Block a user