新增检测通知权限弹窗

This commit is contained in:
zlzw 2022-11-17 17:21:05 +08:00
parent 06d241c66c
commit a61a41a068
3 changed files with 38 additions and 4 deletions

View File

@ -82,7 +82,7 @@
<!-- Android11新增 --> <!-- Android11新增 -->
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />--> <!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />-->
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
<application <application
android:name="com.shayu.phonelive.AppContext" android:name="com.shayu.phonelive.AppContext"
android:allowBackup="true" android:allowBackup="true"

View File

@ -3,6 +3,8 @@ package com.shayu.phonelive.activity;
import static com.yunbao.common.CommonAppContext.logger; import static com.yunbao.common.CommonAppContext.logger;
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
import android.Manifest;
import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.os.Build;
@ -21,6 +23,7 @@ import android.widget.ImageView;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationManagerCompat;
import com.adjust.sdk.Adjust; import com.adjust.sdk.Adjust;
import com.adjust.sdk.AdjustEvent; import com.adjust.sdk.AdjustEvent;
@ -47,6 +50,7 @@ import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager; import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DownloadUtil; import com.yunbao.common.utils.DownloadUtil;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
import com.yunbao.common.utils.LogUtil; import com.yunbao.common.utils.LogUtil;
@ -140,6 +144,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
}; };
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000); mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
LogUtil.uploadErrorLog(AppContext.sInstance); LogUtil.uploadErrorLog(AppContext.sInstance);
SpUtil.getInstance().setBooleanValue("NOTIFICATION", NotificationManagerCompat.from(this).areNotificationsEnabled());
} }

View File

@ -7,16 +7,19 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.app.NotificationChannel; import android.app.NotificationChannel;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.ClipData; import android.content.ClipData;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.Display; import android.view.Display;
@ -29,6 +32,9 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
import com.alibaba.android.arouter.facade.annotation.Route; import com.alibaba.android.arouter.facade.annotation.Route;
@ -202,7 +208,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
CommonHttpUtil.getConfig(mContext, new CommonCallback<ConfigBean>() { CommonHttpUtil.getConfig(mContext, new CommonCallback<ConfigBean>() {
@Override @Override
public void callback(ConfigBean bean) { public void callback(ConfigBean bean) {
if(bean==null){ if (bean == null) {
return; return;
} }
//是否需要老用户回归弹窗 //是否需要老用户回归弹窗
@ -417,7 +423,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
} }
@Override @Override
public void onNext(kotlin.Unit unit) { public void onNext(Unit unit) {
String Uid = floatBanner.getUid(); String Uid = floatBanner.getUid();
LiveHttpUtil.getLiveInfo(Uid + "", new HttpCallback() { LiveHttpUtil.getLiveInfo(Uid + "", new HttpCallback() {
@Override @Override
@ -477,6 +483,29 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
//获取指导员账号 //获取指导员账号
ConversationIMListManager.get(this).getUserInstructor(this); ConversationIMListManager.get(this).getUserInstructor(this);
checkVersion(); checkVersion();
if(!SpUtil.getInstance().getBooleanValue("NOTIFICATION")){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
this.requestPermissions(new String[]{Manifest.permission.ACCESS_NOTIFICATION_POLICY,Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE}, 233);
}
DialogUitl.showSimpleDialog(this, "应用需要通知权限", new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
Intent intent = new Intent();
intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
intent.putExtra("app_package", getPackageName());
intent.putExtra("app_uid", getApplicationInfo().uid);
// for Android 8 and above
intent.putExtra("android.provider.extra.APP_PACKAGE", getPackageName());
startActivity(intent);
}
});
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
Log.i("权限","requestCode = " + requestCode + ", permissions = " + Arrays.deepToString(permissions) + ", grantResults = " + Arrays.toString(grantResults));
} }
@Override @Override
@ -729,7 +758,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
bundle.putString("send_exp", obj.getString("send_exp")); bundle.putString("send_exp", obj.getString("send_exp"));
bundle.putString("sign_day", obj.getString("sign_day")); bundle.putString("sign_day", obj.getString("sign_day"));
fragment.setArguments(bundle); fragment.setArguments(bundle);
if(!getSupportFragmentManager().isStateSaved()) { if (!getSupportFragmentManager().isStateSaved()) {
fragment.show(getSupportFragmentManager(), "SigninDialog"); fragment.show(getSupportFragmentManager(), "SigninDialog");
} }
} }