How do I show the Google permission request dialog above / through screen lock?

I am trying to show Google geolocation services (turn on GPS, network data, etc.). The dialog box locks the screen.

I use KeyguardManager to turn off the lock screen. This works great since my MainActivity can turn off the lock screen. However, as soon as the Google Location Services dialog box appears, the lock screen is back on, the screen is locked, and I cannot get to my MainActivity if I do not unlock the screen.

I even tried ... Flag_Show_When_Locked, but that didn't help.

Here is my code:

private KeyguardLock DisableScreenLock; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); setContentView(R.main_layout); KeyguardManager myKeyGuard = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE); DisableScreenLock = myKeyGuard.newKeyguardLock("disableKeyguard"); DisableScreenLock.disableKeyguard(); } protected synchronized void GoogleApiClient_Intialize() { Log.e(TAG, "Building GoogleApiClient"); googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } protected void LocationRequest_Intialize() { locationRequest = new LocationRequest(); locationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS); locationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); } protected void LocationSettingsRequest_Builder() { LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); builder.addLocationRequest(locationRequest); locationSettingsRequest = builder.build(); } @Override public void onConnected(Bundle connectionHint) { Log.e(TAG, "GoogleApiClient is connected"); LocationSettings_Check_Start(); } protected void LocationSettings_Check_Start() { PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings( googleApiClient, locationSettingsRequest); result.setResultCallback(this); } 

In any case, I can show this Google Location Services dialog using password / template / output, etc. lock screen?

Many thanks for your help.

enter image description here

+6
source share

All Articles