我需要用户为我的应用启用Notification Listener权限。现在我只是开始一个新活动,如下所示,但是当用户允许该权限时,它会自动回到我的活动中吗?
startActivity(new Intent(android.provider.Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS));
答案 0 :(得分:0)
我想通过创建一个处理程序来解决这个问题,如果通知监听器包含我的包,那么每半秒检查一次,当true时再次打开我的活动。
final Handler handler = new Handler();
final int delay = 500; //milliseconds
mRunnable = new Runnable() {
@Override
public void run() {
if((!NotificationManagerCompat.getEnabledListenerPackages(getActivity()).contains(BuildConfig.APPLICATION_ID))){
handler.postDelayed(mRunnable, delay);
}else{
Intent LaunchIntent = getActivity().getIntent();
startActivity(LaunchIntent);
//LaunchIntent.finish();
handler.removeCallbacks(mRunnable);
}
}
};
handler.postDelayed(mRunnable, delay);*/