【发布时间】:2016-02-24 04:45:06
【问题描述】:
我正在尝试通过锁定屏幕显示 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);
}
无论如何我可以通过密码/模式/pin 等显示此 Google 位置服务对话框吗?锁定屏幕?
非常感谢您的帮助。
【问题讨论】:
-
我不确定,但我认为这是不可能的,因为需要解锁设备才能访问设置,这基本上就是这里发生的事情。
-
我建议你开始对你的问题进行赏金,让有能力回答的人更容易看到它。
-
谢谢大家。我希望其他人可以帮助我。
-
我认为它不可能在锁定屏幕上显示任何对话框,但是您可以使用
Notification伪造它购买,一旦用户选择通知然后显示位置权限。
标签: android lockscreen android-networking location-services android-gps