I'm trying to show the Google Location Services (turn on GPS, network data, etc.) Dialog through lock screen.
I'm using KeyguardManager to disable Lock screen. This works fine as my MainActivity is able to disable the lock screen. However, as soon as the Google Location Services Dialog shows up, the lock screen is back to enable, the screen is locked and I can't get to my MainActivity unless I unlock the screen.
I've even tried ...Flag_Show_When_Locked, but it 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);
}
Is there anyway I can show this Google Location Services Dialog through password/pattern/pin, etc.. lock screen?
Thank you very much for your help.
Notification
, once user selects the notification then display location permission. – Isodiametric