SettingsApi已弃用

时间:2018-05-09 10:21:29

标签: android gps location client

直到上次更新我才使用下一个代码:

int getTheDiff(int[] A){
    int diff1=0, diff2=0;
    for(int i=0, j=A.length-1; i<j;i++){
        if(A[i]!=A[j])
            diff1 = Math.max(j-i, diff1);
    }
    for(int i=A.length-1, j=0; i>j;i--){
        if(A[i]!=A[j])
            diff2 = Math.max(j-i, diff2);
    }
    return Math.max(diff1, diff2);
}

不幸的是,在更新了一条警告消息后,不推荐使用LocationServices.SettingsApi。如何更改我的代码以适应新的uodates?

1 个答案:

答案 0 :(得分:5)

SettingsApi界面 已弃用 。您应该使用基于GoogleApi的API SettingsClient

  

公共类SettingsClient扩展   GoogleApi

此API可让应用程序轻松确保为应用程序的位置需求正确配置设备的系统设置。

<div class="col-lg-6">
    <h5>Whether College/Student?</h5>
    <div class="form-group form-check-inline">
        <label class="custom-control custom-radio">
            <input id="radio" name="radio" value="0" type="radio" class="custom-control-input">
            <span class="custom-control-indicator"></span>
            <span class="custom-control-description">College</span>
        </label>
    </div>
    <div class="form-group form-check-inline">
        <label class="custom-control custom-radio">
            <input id="radio" name="radio" value="1" type="radio" class="custom-control-input">
            <span class="custom-control-indicator"></span>
            <span class="custom-control-description">Student</span>
        </label>
    </div>
</div>