Google API BeaconStateResult类中getBeaconState()接口HMS不再支持:
类型 | BeaconStateResult类中的Google API |
|---|---|
方法 | BeaconStateResult.getBeaconState() |
您需要使用HMS中的BeaconStatusResponse中的getBeaconStatus()接口来代替。
Google API | To HMS API | Add HMS API |
|---|---|---|
BeaconStateResult.getBeaconState() | BeaconStateResponse.getBeaconState() |
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Awareness.API).build();
mGoogleApiClient.connect();
// 发起请求
Awareness.SnapshotApi.getBeaconState(mGoogleApiClient, BEACON_TYPE_FILTERS).setResultCallback(new ResultCallback<BeaconStateResult>() {
@Override
public void onResult(@NonNull BeaconStateResult beaconStateResult) {
// 得到结果
if (beaconStateResult.getStatus().isSuccess()) {
BeaconState beaconState = beaconStateResult.getBeaconState();
}
}
}); BeaconStateResult类中getBeaconState()接口To HMS API方法:
// 发起请求
Awareness.getCaptureClient(this).getBeaconStatus(BEACON_TYPE_FILTERS).addOnSuccessListener(new OnSuccessListener<BeaconStatusResponse>() {
@Override
public void onSuccess(BeaconStatusResponse beaconStatusResponse) {
// 得到结果
BeaconStatus beaconStatus = beaconStatusResponse.getBeaconStatus();
}
}); BeaconStateResult类中getBeaconState()接口Add HMS API方法:
Awareness.getSnapshotClient(this).getBeaconState(BEACON_TYPE_FILTERS).addOnSuccessListener(new OnSuccessListener<BeaconStateResponse>() {
@Override
public void onSuccess(BeaconStateResponse param0) {
// 得到结果
BeaconState beaconState = param0.getBeaconState();
}
}); Google API DetectedActivityResult类中getActivityRecognitionResult()接口HMS不再支持:
类型 | DetectedActivityResult类中的Google API |
|---|---|
方法 | DetectedActivityResult.getActivityRecognitionResult() |
您需要使用HMS中的BehaviorResponse中的getBehaviorStatus()接口来代替。
Google API | To HMS API | Add HMS API |
|---|---|---|
DetectedActivityResult.getActivityRecognitionResult() | DetectedActivityResponse.getActivityRecognitionResult() |
DetectedActivityResult类中getActivityRecognitionResult()接口Google API实现方法:
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Awareness.API).build();
mGoogleApiClient.connect();
// 发起请求
Awareness.SnapshotApi.getDetectedActivity(mGoogleApiClient).setResultCallback(new ResultCallback<DetectedActivityResult>() {
@Override
public void onResult(@NonNull DetectedActivityResult detectedActivityResult) {
// 得到结果
if (detectedActivityResult.getStatus().isSuccess()) {
ActivityRecognitionResult activityRecognitionResult = detectedActivityResult.getActivityRecognitionResult();
long time = activityRecognitionResult.getTime();
long elapsedTime = activityRecognitionResult.getElapsedRealtimeMillis();
DetectedActivity detectedActivity = activityRecognitionResult.getMostProbableActivity();
List<DetectedActivity> detectedActivities = activityRecognitionResult.getProbableActivities();
}
}
}); DetectedActivityResult类中getActivityRecognitionResult()接口To HMS API方法:
// 发起请求
Awareness.getCaptureClient(this).getBehavior().addOnSuccessListener(new OnSuccessListener<BehaviorResponse>() {
@Override
public void onSuccess(BehaviorResponse behaviorResponse) {
// 得到结果
BehaviorStatus behaviorStatus = behaviorResponse.getBehaviorStatus();
long time = behaviorStatus.getTime();
long elapsedTime = behaviorStatus.getElapsedRealtimeMillis();
DetectedBehavior detectedBehavior = behaviorStatus.getMostLikelyBehavior();
List<DetectedBehavior> detectedBehaviors = behaviorStatus.getProbableBehavior();
}
}); DetectedActivityResult类中getActivityRecognitionResult()接口Add HMS API方法:
// 发起请求
Awareness.getSnapshotClient(this).getDetectedActivity().addOnSuccessListener(new OnSuccessListener<DetectedActivityResponse>() {
@Override
public void onSuccess(DetectedActivityResponse param0) {
// 得到结果
ActivityRecognitionResult activityRecognitionResult = param0.getActivityRecognitionResult();
}
}); Google API DetectedActivityResponse类中getActivityRecognitionResult()接口在To HMS API情况下不能自动转换,您需要手动转换。
类型 | DetectedActivityResponse类中的Google API |
|---|---|
方法 | DetectedActivityResponse.getActivityRecognitionResult() |
Awareness与Location的部分方法重复,当使用To HMS API工具转换时,转换的是Location对应的类/方法/常量,您需要手工转换为Awareness对应的类/方法/常量,Location与Awareness需要转换类/方法/常量对比如下:
类型 | Location | Awareness |
|---|---|---|
类 | ||
方法 | ||
方法 | ||
方法 | ActivityIdentificationResponse.getMostActivityIdentification() | |
方法 | ActivityIdentificationResponse.getActivityIdentificationDatas() | |
方法 | ||
方法 | ||
常量 | ||
常量 | ||
常量 | ||
常量 | ||
常量 | ||
常量 |
DetectedActivityResponse类中getActivityRecognitionResult()接口Google API实现方法:
// 发起请求
Awareness.getSnapshotClient(this).getDetectedActivity().addOnSuccessListener(new OnSuccessListener<DetectedActivityResponse>() {
@Override
public void onSuccess(DetectedActivityResponse detectedActivityResponse) {
// 得到结果
ActivityRecognitionResult activityRecognitionResult = detectedActivityResponse.getActivityRecognitionResult();
long time = activityRecognitionResult.getTime();
long elapsedTime = activityRecognitionResult.getElapsedRealtimeMillis();
DetectedActivity detectedActivity = activityRecognitionResult.getMostProbableActivity();
List<DetectedActivity> detectedActivities = activityRecognitionResult.getProbableActivities();
int type = detectedActivity.getType();
int confidence = detectedActivity.getConfidence();
}
}); DetectedActivityResponse类中getActivityRecognitionResult()接口To HMS API方法:
// 发起请求
Awareness.getCaptureClient(this).getBehavior().addOnSuccessListener(new OnSuccessListener<BehaviorResponse>() {
@Override
public void onSuccess(BehaviorResponse behaviorResponse) {
// 得到结果
BehaviorStatus behaviorStatus = behaviorResponse.getBehaviorStatus();
long time = behaviorStatus.getTime();
long elapsedTime = behaviorStatus.getElapsedRealtimeMillis();
DetectedBehavior detectedBehavior = behaviorStatus.getMostLikelyBehavior();
List<DetectedBehavior> detectedBehaviors = behaviorStatus.getProbableBehavior();
// This type should match BehaviorBarrier
int type = detectedBehavior.getType();
int confidence = detectedBehavior.getConfidence();
}
}); Google API FenceQueryResult类中getFenceStateMap()接口HMS不再支持:
类型 | FenceQueryResult类中的Google API |
|---|---|
方法 | FenceQueryResult.getFenceStateMap() |
您需要使用HMS中的BarrierQueryResponse中的getBarrierStatusMap()接口来代替。
Google API | To HMS API | Add HMS API |
|---|---|---|
FenceQueryResult.getFenceStateMap() | FenceQueryResponse.getFenceStateMap() |
FenceQueryResult类中getFenceStateMap()接口Google API实现方法:
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Awareness.API).build();
mGoogleApiClient.connect();
// 构建请求体
FenceQueryRequest fenceQueryRequest = FenceQueryRequest.all();
// 发起请求
Awareness.FenceApi.queryFences(mGoogleApiClient, fenceQueryRequest).setResultCallback(new ResultCallback<FenceQueryResult>() {
// 得到结果
@Override
public void onResult(FenceQueryResult fenceQueryResult) {
for (String key : fenceQueryResult.getFenceStateMap().getFenceKeys()) {
FenceState fenceStatus = fenceQueryResult.getFenceStateMap().getFenceState(key);
}
}
}); FenceQueryResult类中getFenceStateMap()接口To HMS API方法:
// 构建请求体
BarrierQueryRequest barrierQueryRequest = BarrierQueryRequest.all();
// 发起请求
Awareness.getBarrierClient(this).queryBarriers(barrierQueryRequest).addOnSuccessListener(new OnSuccessListener<BarrierQueryResponse>() {
@Override
// 得到结果
public void onSuccess(BarrierQueryResponse barrierQueryResponse) {
for (String key : barrierQueryResponse.getBarrierStatusMap().getBarrierLabels()) {
BarrierStatus barrierStatus = barrierQueryResponse.getBarrierStatusMap().getBarrierStatus(key);
}
}
}); FenceQueryResult类中getFenceStateMap()接口Add HMS API方法:
// 构建请求体
FenceQueryRequest fenceQueryRequest = FenceQueryRequest.all();
// 发起请求
Awareness.getFenceClient(this).queryFences(fenceQueryRequest).addOnSuccessListener(new OnSuccessListener<FenceQueryResponse>() {
@Override
public void onSuccess(FenceQueryResponse param0) {
// 得到结果
for (String key : param0.getFenceStateMap().getFenceKeys()) {
FenceState fenceState = param0.getFenceStateMap().getFenceState(key);
}
}
}); Google API HeadphoneStateResult类中getHeadphoneState()接口HMS不再支持:
类型 | Google API |
|---|---|
方法 | HeadphoneStateResult.getHeadphoneState() |
您需要使用HMS中的HeadsetStatusResponse中的getHeadsetStatus()接口来代替。
Google API | To HMS API | Add HMS API |
|---|---|---|
HeadphoneStateResult.getHeadphoneState() | HeadphoneStateResponse.getHeadphoneState |
HeadphoneStateResult类中getHeadphoneState()接口Google API实现方法:
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Awareness.API).build();
mGoogleApiClient.connect();
// 发起请求
Awareness.SnapshotApi.getHeadphoneState(mGoogleApiClient).setResultCallback(new ResultCallback<HeadphoneStateResult>() {
@Override
public void onResult(@NonNull HeadphoneStateResult headphoneStateResult) {
// 得到结果
if (headphoneStateResult.getStatus().isSuccess()) {
HeadphoneState headphoneState = headphoneStateResult.getHeadphoneState();
}
}
}); HeadphoneStateResult类中getHeadphoneState()接口To HMS API方法:
// 发起请求
Awareness.getCaptureClient(this).getHeadsetStatus().addOnSuccessListener(new OnSuccessListener<HeadsetStatusResponse>() {
@Override
public void onSuccess(HeadsetStatusResponse headsetStatusResponse) {
// 得到结果
HeadsetStatus headsetStatus = headsetStatusResponse.getHeadsetStatus();
}
}); HeadphoneStateResult类中getHeadphoneState()接口Add HMS API方法:
// 发起请求
Awareness.getSnapshotClient(this).getHeadphoneState().addOnSuccessListener(new OnSuccessListener<HeadphoneStateResponse>() {
@Override
public void onSuccess(HeadphoneStateResponse param0) {
// 得到结果
HeadphoneState headphoneState = param0.getHeadphoneState();
}
}); Google API LocationResult类中getLocation()接口HMS不再支持:
类型 | LocationResult类中的Google API |
|---|---|
方法 | LocationResult.getLocation() |
您需要使用HMS中的LocationResponse中的getLocation()接口来代替。
Google API | To HMS API | Add HMS API |
|---|---|---|
LocationResult.getLocation() | LocationResponse.getLocation() |
LocationResult类中getLocation()接口Google API实现方法:
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Awareness.API).build();
mGoogleApiClient.connect();
// 发起请求
Awareness.SnapshotApi.getLocation(mGoogleApiClient).setResultCallback(new ResultCallback<LocationResult>() {
@Override
public void onResult(@NonNull LocationResult locationResult) {
// 得到结果
if (locationResult.getStatus().isSuccess()) {
Location location = locationResult.getLocation();
}
}
}); LocationResult类中getLocation()接口To HMS API方法:
// 发起请求
Awareness.getCaptureClient(this).getLocation().addOnSuccessListener(new OnSuccessListener<LocationResponse>() {
@Override
public void onSuccess(LocationResponse locationResponse) {
// 得到结果
Location location = locationResponse.getLocation();
}
}); LocationResult类中getLocation()接口Add HMS API方法:
// 发起请求
Awareness.getSnapshotClient(this).getLocation().addOnSuccessListener(new OnSuccessListener<LocationResponse>() {
@Override
public void onSuccess(LocationResponse param0) {
// 得到结果
Location location = param0.getLocation();
}
}); Google API TimeIntervalsResult类中getTimeIntervals()接口HMS不再支持:
类型 | TimeIntervalsResult 类中的Google API |
|---|---|
方法 | TimeIntervalsResult.getTimeIntervals() |
您需要使用HMS中的TimeCategoriesResponse中的getTimeCategories()接口来代替。
Google API | To HMS API | Add HMS API |
|---|---|---|
TimeIntervalsResult.getTimeIntervals() | TimeIntervalsResponse.getTimeIntervals() |
TimeIntervalsResult类中getTimeIntervals()接口Google API实现方法:
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Awareness.API).build();
mGoogleApiClient.connect();
// 发起请求
Awareness.SnapshotApi.getTimeIntervals(mGoogleApiClient).setResultCallback(new ResultCallback<TimeIntervalsResult>() {
@Override
public void onResult(@NonNull TimeIntervalsResult timeIntervalsResult) {
// 得到结果
if (timeIntervalsResult.getStatus().isSuccess()) {
TimeIntervals timeIntervals = timeIntervalsResult.getTimeIntervals();
}
}
}); TimeIntervalsResult类中getTimeIntervals()接口To HMS API方法:
// 发起请求
Awareness.getCaptureClient(this).getTimeCategories().addOnSuccessListener(new OnSuccessListener<TimeCategoriesResponse>() {
@Override
public void onSuccess(TimeCategoriesResponse timeCategoriesResponse) {
// 得到结果
TimeCategories timeCategories = timeCategoriesResponse.getTimeCategories();
}
}); TimeIntervalsResult类中getTimeIntervals()接口Add HMS API方法:
// 发起请求
Awareness.getSnapshotClient(this).getTimeIntervals().addOnSuccessListener(new OnSuccessListener<TimeIntervalsResponse>() {
@Override
public void onSuccess(TimeIntervalsResponse param0) {
// 得到结果
TimeIntervals timeIntervals = param0.getTimeIntervals();
}
}); 在HMS最新的API中以下Google API方法/常量已经被废弃。
类型 | 已废弃的Google API | To HMS API | Add HMS API |
|---|---|---|---|
属性 | Awareness.Api | 不提供 | 不提供 |
方法 | SnapshotApi.getPlaces(GoogleApiClient) | 不提供 | 不提供 |
方法 | SnapshotApi.getWeather(GoogleApiClient) | 不提供 | 不提供 |
方法 | SnapshotClient.getPlaces() | 不提供 | 不提供 |
方法 | SnapshotClient.getWeather() | 不提供 | 不提供 |
方法 | PlacesResponse.getPlaceLikelihoods() | 不提供 | 不提供 |
方法 | PlacesResult.getPlaceLikelihoods() | 不提供 | 不提供 |
方法 | WeatherResponse.getWeather() | 不提供 | 不提供 |
方法 | WeatherResult.getWeather() | 不提供 | 不提供 |
方法 | Weather.getConditions() | 不提供 | 不提供 |
方法 | Weather.getDewPoint(int) | 不提供 | 不提供 |
方法 | Weather.getFeelsLikeTemperature(int) | 不提供 | 不提供 |
方法 | Weather.getHumidity() | 不提供 | 不提供 |
方法 | Weather.getTemperature(int) | 不提供 | 不提供 |
常量 | Weather.CELSIUS | 不提供 | 不提供 |
常量 | Weather.CONDITION_CLEAR | 不提供 | 不提供 |
常量 | Weather.CONDITION_CLOUDY | 不提供 | 不提供 |
常量 | Weather.CONDITION_FOGGY | 不提供 | 不提供 |
常量 | Weather.CONDITION_HAZY | 不提供 | 不提供 |
常量 | Weather.CONDITION_ICY | 不提供 | 不提供 |
常量 | Weather.CONDITION_RAINY | 不提供 | 不提供 |
常量 | Weather.CONDITION_SNOWY | 不提供 | 不提供 |
常量 | Weather.CONDITION_STORMY | 不提供 | 不提供 |
常量 | Weather.CONDITION_UNKNOWN | 不提供 | 不提供 |
常量 | Weather.CONDITION_WINDY | 不提供 | 不提供 |
常量 | Weather.FAHRENHEIT | 不提供 | 不提供 |
Awareness类中Google API已废弃的接口如下:
类型 | 废弃API | 替换API |
|---|---|---|
属性 | Awareness.FenceApi | Awareness.getFenceClient(Activity activity) |
属性 | Awareness.SnapshotApi | Awareness.getSnapshotClient(Activity activity) |
您需要先将使用到的Google API Awareness类中已废弃API升级到Google API提供的替换API getFenceClient(Activity activity)、getSnapshotClient(Activity activity),然后使用工具自动转换。若不升级API,可以按照以下指导手工转换。
Google API Awareness类中Google API已废弃的接口转换为HMS相关接口如下:
Google API | To HMS API | Add HMS API |
|---|---|---|
Awareness.FenceApi | Awareness.getFenceClient(Activity activity) | |
Awareness.SnapshotApi | Awareness.getSnapshotClient(Activity activity) |
FenceApi接口To HMS API方法:
Awareness.getBarrierClient(Activity);
FenceApi接口Add HMS API方法:
Awareness.getFenceClient(Activity);
SnapshotApi接口To HMS API方法:
Awareness.getCaptureClient(Activity);
SnapshotApi接口Add HMS API方法:
Awareness.getSnapshotClient(Activity);
Google API FenceApi类中已废弃的接口如下:
类型 | 废弃API | 替换API |
|---|---|---|
方法 | FenceApi.queryFences(GoogleApiClient, FenceQueryRequest) | FenceClient.queryFences(FenceQueryRequest) |
方法 | FenceApi.updateFences(GoogleApiClient, FenceUpdateRequest) | FenceClient.updateFences(FenceQueryRequest) |
您需要先将使用到的Google API FenceApi类中已废弃接口升级到替换API queryFences(FenceQueryRequest)、updateFences(FenceQueryRequest),然后使用工具自动转换。若不升级API,可以按照以下指导进行手工转换。
Google API | To HMS API | Add HMS API |
|---|---|---|
FenceApi.queryFences(GoogleApiClient, FenceQueryRequest) | FenceClient.queryFences(FenceQueryRequest) | |
FenceApi.updateFences(GoogleApiClient, FenceUpdateRequest) | FenceClient.updateFences(FenceQueryRequest) |
queryFences(GoogleApiClient, FenceQueryReqest)接口Google API实现方法:
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Awareness.API).build();
mGoogleApiClient.connect();
// 构建请求体
FenceQueryRequest request = FenceQueryRequest.all();
// 发起请求
Awareness.FenceApi.queryFences(mGoogleApiClient, request).setResultCallback(new ResultCallback<FenceQueryResult>() {
@Override
public void onResult(FenceQueryResult fenceQueryResult) {
// 处理结果
...
}
}); queryFences(GoogleApiClient, FenceQueryRequest)接口To HMS API方法:
// 构建请求体
BarrierQueryRequest query = BarrierQueryRequest.all();
// 发起请求
Awareness.getBarrierClient(this).queryBarriers(query).addOnSuccessListener(new OnSuccessListener<BarrierQueryResponse>() {
@Override
public void onSuccess(BarrierQueryResponse barrierQueryResponse) {
// 处理结果
...
}
}); queryFences(GoogleApiClient, FenceQueryRequest)接口Add HMS API方法:
// 构建请求体
FenceQueryRequest query = FenceQueryRequest.all();
// 发起请求
Awareness.getFenceClient(this).queryFences(query).addOnSuccessListener(new OnSuccessListener<FenceQueryResponse>() {
@Override
public void onSuccess(FenceQueryResponse param0) {
// 处理结果
...
}
}); updateFences(GoogleApiClient, FenceUpdateRequest)接口Google API实现方法:
GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this).addApi(Awareness.API).build();
googleApiClient.connect();
// 构建围栏
AwarenessFence headphoneFence = HeadphoneFence.pluggingIn();
Intent intent = new Intent();
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
// 更新围栏
Awareness.FenceApi.updateFences(googleApiClient, new FenceUpdateRequest.Builder()
.addFence("HEAD_PHONE_CONNECTING", headphoneFence,pendingIntent)
.build()); updateFences(GoogleApiClient, FenceUpdateRequest)接口To HMS API方法:
// 构建围栏
AwarenessBarrier headsetBarrier = HeadsetBarrier.connecting();
Intent intent = new Intent();
PendingIntent pendingIntent=PendingIntent.getBroadcast(this, 0, intent,PendingIntent.FLAG_UPDATE_CURRENT);
// 更新围栏
Awareness.getBarrierClient(this).updateBarriers(new BarrierUpdateRequest.Builder()
.addBarrier("HEAD_SET_CONNECTING", headsetBarrier, pendingIntent)
.build()); updateFences(GoogleApiClient, FenceQueryRequest)接口Add HMS API方法:
// 构建围栏
AwarenessFence headphoneFence = HeadphoneFence.pluggingIn();
Intent intent = new Intent();
PendingIntent pendingIntent=PendingIntent.getBroadcast(this, 0, intent,PendingIntent.FLAG_UPDATE_CURRENT);
// 更新围栏
Awareness.getFenceClient(this).updateFences(new FenceUpdateRequest.Builder()
.addFence("HEAD_PHONE_CONNECTING",headphoneFence,pendingIntent)
.build()); Google API SnapshotApi类中已废弃的接口如下:
类型 | 废弃API | 替换API |
|---|---|---|
方法 | SnapshotApi.getDetectedActivity(GoogleApiClient) | SnapshotClient.getDetectedActivity() |
方法 | SnapshotApi.getHeadphoneState(GoogleApiClient) | SnapshotClient.getHeadphoneState() |
方法 | SnapshotApi.getLocation(GoogleApiClient) | SnapshotClient.getLocation() |
方法 | SnapshotApi.getTimeIntervals(GoogleApiClient) | SnapshotClient.getTimeIntervals() |
方法 | SnapshotApi.getBeaconState(GoogleApiClient, Collection<BeaconState.TypeFilter>) | SnapshotClient.getBeaconState (Collection<BeaconState. TypeFilter>)( |
方法 | SnapshotApi.getBeaconState(GoogleApiClient, TypeFilter...) | SnapshotClient.getBeaconState(BeaconState.TypeFilter…) |
您需要先将使用到的SnapshotApi类中已废弃接口升级到Google API提供的新API getBeaconState(BeaconState.Filter...)、getDetectedActivity()、getHeadphoneState()、getLocation()、getTimeIntervals(),然后使用工具自动转换。若不升级API,可以按照以下指导手工转换。
Google API | To HMS API | Add HMS API |
|---|---|---|
SnapshotApi.getDetectedActivity(GoogleApiClient) | SnapshotClient.getDetectedActivity() | |
SnapshotApi.getHeadphoneState(GoogleApiClient) | SnapshotClient.getHeadphoneState() | |
SnapshotApi.getLocation(GoogleApiClient) | SnapshotClient.getLocation() | |
SnapshotApi.getTimeIntervals(GoogleApiClient) | SnapshotClient.getTimeIntervals() | |
SnapshotApi.getBeaconState(GoogleApiClient, Collection<BeaconState.TypeFilter>) | CaptureClient.getBeaconStatus(Collection<BeaconStatus.Filter>) | SnapshotClient.getBeaconState (Collection<BeaconState. TypeFilter>) |
SnapshotApi.getBeaconState(GoogleApiClient, TypeFilter...) | SnapshotClient.getBeaconState(BeaconState.TypeFilter…) |
getDetectedActivity(GoogleApiClient)接口Google API实现方法:
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Awareness.API).build();
mGoogleApiClient.connect();
// 发起请求
Awareness.SnapshotApi.getDetectedActivity(mGoogleApiClient).setResultCallback(new ResultCallback<DetectedActivityResult>() {
@Override
public void onResult(@NonNull DetectedActivityResult detectedActivityResult) {
// 得到结果
if (detectedActivityResult.getStatus().isSuccess()) {
...
}
}
}); getDetectedActivity(GoogleApiClient)接口To HMS API方法:
Awareness.getCaptureClient(this).getBehavior().addOnSuccessListener(new OnSuccessListener<BehaviorResponse>() {
@Override
public void onSuccess(BehaviorResponse behaviorResponse) {
…
}
}); getDetectedActivity(GoogleApiClient)接口Add HMS API方法:
Awareness.getSnapshotClient(this).getDetectedActivity().addOnSuccessListener(new OnSuccessListener<DetectedActivityResponse>() {
@Override
public void onSuccess(DetectedActivityResponse param0) {
…
}
}); getHeadphoneState(GoogleApiClient)接口Google API实现方法:
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Awareness.API).build();
mGoogleApiClient.connect();
// 发起请求
Awareness.SnapshotApi.getHeadphoneState(mGoogleApiClient).setResultCallback(new ResultCallback<HeadphoneStateResult>() {
@Override
public void onResult(@NonNull HeadphoneStateResult headphoneStateResult) {
// 得到结果
if (headphoneStateResult.getStatus().isSuccess()) {
...
}
}
}); getHeadphoneState(GoogleApiClient)接口To HMS API方法:
Awareness.getCaptureClient(this).getHeadsetStatus().addOnSuccessListener(new OnSuccessListener<HeadsetStatusResponse>() {
@Override
public void onSuccess(HeadsetStatusResponse headsetStatusResponse) {
…
}
}); getHeadphoneState(GoogleApiClient)接口Add HMS API方法:
Awareness.getSnapshotClient(this).getHeadphoneState().addOnSuccessListener(new OnSuccessListener<HeadphoneStateResponse>() {
@Override
public void onSuccess(HeadphoneStateResponse param0) {
…
}
}); getLocation(GoogleApiClient)接口Google API实现方法:
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Awareness.API).build();
mGoogleApiClient.connect();
// 发起请求
Awareness.SnapshotApi.getLocation(mGoogleApiClient).setResultCallback(new ResultCallback<LocationResult>() {
@Override
public void onResult(@NonNull LocationResult locationResult) {
// 得到结果
if (locationResult.getStatus().isSuccess()) {
...
}
}
}); getLocation(GoogleApiClient)接口To HMS API方法:
// 检查位置权限
if(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)!=PackageManager.PERMISSION_GRANTED) {
return;
}
// 发起请求
Awareness.getCaptureClient(this).getLocation().addOnSuccessListener(new OnSuccessListener<LocationResponse>() {
@Override
public void onSuccess(LocationResponse locationResponse) {
//处理结果
…
}
}); getLocation(GoogleApiClient)接口Add HMS API方法:
// 检查位置权限
if(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) !=PackageManager.PERMISSION_GRANTED) {
return;
}
// 发起请求
Awareness.getSnapshotClient(this).getLocation().addOnSuccessListener(new OnSuccessListener<LocationResponse>() {
@Override
public void onSuccess(LocationResponse param0) {
//处理结果
…
}
}); GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Awareness.API).build();
mGoogleApiClient.connect();
// 发起请求
Awareness.SnapshotApi.getBeaconState(mGoogleApiClient, BEACON_TYPE_FILTERS).setResultCallback(new ResultCallback<BeaconStateResult>() {
@Override
public void onResult(BeaconStateResult beaconStateResult) {
// 处理结果
if (beaconStateResult.getStatus().isSuccess()) {
...
}
}
}); getBeaconState(TypeFilter...)接口To HMS API方法:getBeaconState(GoogleApiClient, Collection<BeaconState.TypeFilter>)方法同理。
// 发起请求
Awareness.getCaptureClient(this).getBeaconStatus(BEACON_TYPE_FILTERS).addOnSuccessListener(new OnSuccessListener<BeaconStatusResponse>(){
@Override
public void onSuccess(BeaconStatusResponse beaconStatusResponse) {
// 处理结果
...
}
}); getBeaconState(TypeFilter...)接口Add HMS API方法:getBeaconState(GoogleApiClient, Collection<BeaconState.TypeFilter>)方法同理。
// 发起请求
Awareness.getSnapshotClient(this).getBeaconState(BEACON_TYPE_FILTERS).addOnSuccessListener(new OnSuccessListener<BeaconStateResponse>(){
@Override
public void onSuccess(BeaconStateResponse param0) {
// 处理结果
...
}
}); getTimeIntervals(GoogleApiClient)接口Google API实现方法:
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Awareness.API).build();
mGoogleApiClient.connect();
// 发起请求
Awareness.SnapshotApi.getTimeIntervals(mGoogleApiClient).setResultCallback(new ResultCallback<TimeIntervalsResult>() {
@Override
public void onResult(@NonNull TimeIntervalsResult timeIntervalsResult) {
//处理结果
if (timeIntervalsResult.getStatus().isSuccess()) {
...
}
}
}); // 发起请求
Awareness.getCaptureClient(this).getTimeCategories().addOnSuccessListener(new OnSuccessListener<TimeCategoriesResponse>() {
@Override
public void onSuccess(TimeCategoriesResponse timeCategoriesResponse) {
//处理结果
…
}
}); getTimeIntervals(GoogleApiClient)接口Add HMS API方法:
// 发起请求
Awareness.getSnapshotClient(this).getTimeIntervals().addOnSuccessListener(new OnSuccessListener<TimeIntervalsResponse>() {
@Override
public void onSuccess(TimeIntervalsResponse param0) {
// 处理结果
…
}
}); Google API AwarenessStatusCodes类中状态码已被废弃,HMS提供新的状态码。
类型 | Google状态码 |
|---|---|
常量 | int ACL_ACCESS_DENIED = 7503 |
常量 | int API_NOT_AVAILABLE = 7512 |
常量 | int BAD_ACCOUNT = 7504 |
常量 | int BLUETOOTH_OFF = 7506 |
常量 | int FENCE_NOT_AVAILABLE = 7514 |
常量 | int INCONSISTENT_ACCOUNT = 7510 |
常量 | int INCONSISTENT_MODULE_ID = 7511 |
常量 | int INCONSISTENT_UID = 7513 |
常量 | int INTERNAL_API_CLIENT_CONNECTION_FAILED = 7507 |
常量 | int MAX_LIMIT_OF_FENCE_REGISTRATIONS_EXCEEDED = 7515 |
类型 | HMS状态码 |
|---|---|
常量 | int AWARENESS_SUCCESS_CODE = 0 |
常量 | int AWARENESS_UNKNOWN_ERROR_CODE = 10000 |
常量 | int AWARENESS_BINDER_ERROR_CODE = 10001 |
常量 | int AWARENESS_REGISTER_FAILED_CODE = 10002 |
常量 | int AWARENESS_TIMEOUT_CODE = 10003 |
常量 | int AWARENESS_COUNT_LIMIT_CODE = 10004 |
常量 | int AWARENESS_FREQUENCY_LIMIT_CODE = 10005 |
常量 | int AWARENESS_BARRIER_PARAMETER_ERROR_CODE = 10006 |
常量 | int AWARENESS_REQUEST_ERROR_CODE = 10007 |
常量 | int AWARENESS_AGC_FILE_ERROR = 10008 |
常量 | int AWARENESS_RESULT_INVALID_ERROR = 10009 |
常量 | int AWARENESS_REMOTE_EXCEPTION_ERROR = 10010 |
常量 | int AWARENESS_WAIT_CALLBACK_CODE = 10011 |
常量 | int AWARENESS_SDK_VERSION_ERROR = 10100 |
常量 | int AWARENESS_LOCATION_NOCACHE_CODE = 10200 |
常量 | int AWARENESS_LOCATION_NOT_AVAILABLE_CODE = 10201 |
常量 | int AWARENESS_LOCATION_PERMISSION_CODE = 10101 |
常量 | int AWARENESS_LOCATION_CORE_PERMISSION_CODE = 10102 |
常量 | int AWARENESS_BEHAVIOR_PERMISSION_CODE = 10103 |
常量 | int AWARENESS_BEACON_NOT_AVAILABLE_CODE = 10300 |