- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我应该用什么来代替它?此外,我针对此地理围栏应用程序的目标是 Android 7.0。
private void addNewGeofence(GeofencingRequest request) {
Log.i(TAG, "GEOFENCE: Adding new Geofence.");
if (checkPermissions()){
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
LocationServices.GeofencingApi.addGeofences(
googleApiClient, request, createGeofencePendingIntent()).setResultCallback(this);
}
}
最佳答案
您使用的 Android 版本与已弃用的 GeofencingApi
的使用无关。 GeofencingApi
是 Google Play 服务的一部分,在 11.0 版中已弃用。
此时,替代的 GeofencingClient
已添加到 Google Play 服务。
因此,您不再需要设置 GoogleApiClient
来访问 Geofencing API。只需设置一个 Geofencing 客户端,然后以与之前调用类似的方式调用它。主要区别在于您不必实现结果回调,您可以添加所需的任何成功/失败/完成回调。
所以对于您的代码,它将是...
client = LocationServices.getGeofencingClient;
...
client.addGeofences(request, createGeofencePendingIntent())
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
// your success code
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// your fail code;
}
});
请注意,在调用此代码之前,您仍然需要检查您的权限。
关于android - "GeofencingAPI is deprecated",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48686772/
这个问题在这里已经有了答案: How to declare or mark a Java method as deprecated? (6 个回答) 关闭8年前。 我可以使用 @Deprecated
我要使用的代码: window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED) 有FLAG_SHOW_WHEN_LOCKED在 A
这个问题已经有答案了: Can I mix MySQL APIs in PHP? (4 个回答) Why shouldn't I use mysql_* functions in PHP? (14 个
我在我的网站上看到以下消息,我该怎么办? Deprecated: Function eregi() is deprecated in D:\wamp\www\cidoc.gov.mz\modules\
我正在弃用一组 Java 类,以便不再使用它们。我不想关闭不推荐使用的编译器警告,但我发现如果我的一个不推荐使用的类导入另一个不推荐使用的类,我也会收到警告。我不想修改我不赞成使用的代码,但我也不想在
这个问题在这里已经有了答案: How to use Ansible's with_item with a variable? (1 个回答) 3年前关闭。 我认为这是产生错误的剧本的一部分。我应该如何
在我的 Eclipse Indigo 中,只有 @Deprecated 有效,但 @deprecated 在评论中无效,知道吗? 例如 // @deprecated <-- not work @Dep
This question already has answers here: How can I convert ereg expressions to preg in PHP? (4个答案) 去年
我正在将代码从以前版本的 Swift 更改为 Swift5。并且有一条警告消息表明此代码不可用。我想更改此代码,但不知道如何更改。 警告代码 func pbkdf2(hash: CCPBKDFAlg
我正在开发使用 Game Center 的游戏,但我收到了下一个警告; ... 'authenticateWithCompletionHandler:' 已弃用:首先在 iOS 6.0 中弃用 好的,
您好,我在错误日志中收到此错误: "PHP 已弃用:自动填充 $HTTP_RAW_POST_DATA 已弃用,并将在未来版本中删除。为避免此警告,请在 php.ini 中将 'always_popul
您好,我在错误日志中收到此错误: "PHP 已弃用:自动填充 $HTTP_RAW_POST_DATA 已弃用,并将在未来版本中删除。为避免此警告,请在 php.ini 中将 'always_popul
CC_MD5 已在 ios14 中弃用,但我的项目至少支持 ios14。我仍然需要 MD5。我应该怎么办?我使用的开发语言是OC 最佳答案 MD5 已被弃用,因为它是一种有缺陷、不安全的算法。如果可以
我在 Xcode 上的这个条目上有以下问题: CLRegion *pushRegion = [[CLRegion alloc] initCircularRegionWithCenter:coordin
所以我有一个代码可以开始录制音频并不断收到上述警告消息。有帮助吗? - (IBAction)recordStart:(id)sender { AVAudioSession *recSessio
我制作了这个返回文档目录中文件大小的函数,它可以工作,但我得到警告,我想修复,函数: -(unsigned long long int)getFileSize:(NSString*)path { NS
我收到警告: >typings ls typings WARN deprecated 2016-08-05: "registry:dt/react#0.14.0+20160423065914" is
问题的表述有点奇怪,但我想要的是 Rspec 中 stub! 的替代方案,它不会产生弃用警告。 场景: 我使用 stub! 在我的帮助程序规范中对某些帮助程序方法进行 stub 。 例如 stub!(
最近我将我的 Rails 版本从 3.2 迁移到 4.2.6,同时我修改了一些 gem,例如回形针 2.3 到 4.3.6。当我运行 rails server 时,我得到以下弃用: DEPRECATI
My Goal: To fix this error and be able to run my app without an error. Error Message: Note:D:\Learni
我是一名优秀的程序员,十分优秀!