我想实现一个对话框,要求用户决定是否要打开位置wifi和gps,但onActivityResult它总是返回0,即使按下确定按钮,更多细节:当wifi和gps关闭时,返回0,但两者都是正确激活(按下确定按钮).当gps打开并关闭wifi时,返回0,但wifi正确激活(按下确定按钮).只有当wifi打开时,gps才会关闭,返回-1,但gps正确激活(按下确定按钮).
我的代码:
public void activategps(){
builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
builder.setAlwaysShow(true);
//builder.setNeedBle(true);
PendingResult<LocationSettingsResult> result =
LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
@Override
public void onResult(LocationSettingsResult result) {
final Status status = result.getStatus();
final LocationSettingsStates state = result.getLocationSettingsStates();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
// All location settings are satisfied. The client can initialize location
// requests here.
//...
Log.i("sms", "estan disponibles");
Toast.makeText(MainActivity.this, "HOLA 1", Toast.LENGTH_SHORT).show();
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
// Location settings are not satisfied. But could be fixed by showing the user
// …Run Code Online (Sandbox Code Playgroud) 我已经很久没有使用过Android了,但是现在我找到了一个新术语Kotlin,所以我怀疑是,Kotlin需要JDK吗?
如果Kotlin将替换为Java,那么JDK就没有必要了,因为据我所知JDK是针对Java开发的,是否正确?
如果它是正确的那么我有其他怀疑(这已经是旧的)为什么JDK用于Android如果已经包含Android SDK?
PD我疯了,我需要一个解释.