2014-06-10 1 views
4

Android에서 프로그래밍 방식으로 아래 설정을 사용 또는 사용 중지 할 수 있는지 확인하는 방법이 있습니까?Android 시스템 보안 알림 확인 프로그래밍 방식의 액세스 설정

Settings > Security > Device Administration > Notification Access > My App 

현재 나는 아래의 방법을 통해 내 응용 프로그램에서 대화 설정을 호출하고있어하지만 설정이 벌써 활성화되어 있다면이 설정을 제시 싶지 않다.

Intent intent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"); 
startActivity(intent); 

답변

0

onBind() 및 onUnbind()의 정적 변수에서 상태를 유지하는 것이 효과가있었습니다.

public boolean onUnbind(Intent mIntent) { 
    boolean mOnUnbind = super.onUnbind(mIntent); 
    Common.isNotificationAccessEnabled = false; 
    return mOnUnbind; 
} 

public IBinder onBind(Intent mIntent) { 
    IBinder mIBinder = super.onBind(mIntent); 
    Common.isNotificationAccessEnabled = true; 
    return mIBinder; 
} 
1

안드로이드 설정 알림 앱을 포함하는지 여부를 판단하려면, 당신은 수행해야합니다

import android.provider.Settings; 

String enabledAppList = Settings.Secure.getString(
     this.getContentResolver(), "enabled_notification_listeners"); 
boolean temp = enabledAppList.contains("youAppName"); 
12

간단

if (Settings.Secure.getString(this.getContentResolver(),"enabled_notification_listeners").contains(getApplicationContext().getPackageName())) 
    { 
     //service is enabled do something 
    } else { 
     //service is not enabled try to enabled by calling... 
     getApplicationContext().startActivity(new Intent(
      "android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS")); 
    } 

'다른'부분은 옵션으로 따라입니다 확인 귀하의 질문입니다

관련 문제