调整通知权限的弹出位置
This commit is contained in:
parent
0429e7ca36
commit
527bb0f1d9
@ -2,7 +2,9 @@ package com.shayu.phonelive.utils;
|
||||
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
@ -17,6 +19,7 @@ import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
@ -34,6 +37,8 @@ import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.shayu.phonelive.activity.LauncherActivity;
|
||||
import com.yunbao.common.bean.NotificationMsgBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.main.activity.MainActivity;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -81,6 +86,20 @@ public class CustomMessageReceiver extends PushMessageReceiver {
|
||||
@Override
|
||||
public boolean onNotificationMessageArrived(Context context, PushType pushType, PushNotificationMessage notificationMessage) {
|
||||
Log.i("gmc", notificationMessage.getPushContent() + "VVV" + notificationMessage.getPushTitle() + "gmc11112222" + notificationMessage.getExtra());
|
||||
if(!SpUtil.getInstance().getBooleanValue("NOTIFICATION")){
|
||||
DialogUitl.showSimpleDialog(context, "应用需要通知权限", 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", context.getPackageName());
|
||||
intent.putExtra("app_uid", context.getApplicationInfo().uid);
|
||||
// for Android 8 and above
|
||||
intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName());
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (notificationMessage.getExtra() == null) {
|
||||
msg.setImg("" + notificationMessage.getSenderPortrait());
|
||||
msg.setTitle(notificationMessage.getPushTitle());
|
||||
|
@ -483,23 +483,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
//获取指导员账号
|
||||
ConversationIMListManager.get(this).getUserInstructor(this);
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user