我想在我的Android应用中使用Google Play服务.正如Google文档所述,我们需要在使用之前检查Google API是否可用.我已经搜索了一些方法来检查它.这是我得到的:
private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我访问Google Api GooglePlayServicesUtil页面时, 请访问https://developers.google.com/android/reference/com/google/android/gms/common/GooglePlayServicesUtil
我发现所有功能都已弃用.例如,该方法
GooglePlayServicesUtil.isGooglePlayServicesAvailable(不建议使用)
谷歌建议使用:
GoogleApiAvailability.isGooglePlayServicesAvailable.
但是,当我尝试使用GoogleApiAvailability.isGooglePlayServicesAvailable时,收到错误消息:

我正在为图像查看器做一个android应用程序.此应用程序将下载图像,并将它们存储在缓存文件夹中.
因此,在缓存文件夹中,图像文件名必须是唯一的.目前,我使用String.hashCode()来生成文件名.
有没有其他更好的方法来获得独特的字符串?
我想跟踪屏幕上的手指触摸.所以我所做的就是在MotionEvent触发时开始记录位置ACTION_DOWN,但我怎么知道动作何时结束ACTION_CANCEL,或者ACTION_UP?
它们之间的确切区别是什么?