我正在尝试通过锁定屏幕显示 Google 位置服务(打开 GPS、网络数据等)对话框。
我正在使用 KeyguardManager 禁用锁定屏幕。这很好用,因为我的 MainActivity 能够禁用锁定屏幕。但是,一旦 Google 位置服务对话框出现,锁定屏幕就会重新启用,屏幕被锁定,除非我解锁屏幕,否则我无法访问我的 MainActivity。
我什至尝试过 ...Flag_Show_When_Locked,但没有帮助。
这是我的代码:
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);
}
无论如何我可以通过密码/模式/密码等显示此 Google 位置服务对话框。锁定屏幕?
非常感谢您的帮助。