我正在使用Android的Places.GeoDataApi,我会根据执行请求的设备的位置获得不同的搜索结果.我需要将结果始终位于边界内.我没有看到在getAutocompletePredictions请求中可以设置的位置.有什么我想念的吗?
我通过以下方式使用GoogleApiClient和Places API获取地址/地点自动填充建议:
Places.GeoDataApi.getAutocompletePredictions()
该方法需要一个GoogleApiClient对象,一个String来自动完成,一个LatLngBounds对象来限制搜索范围.这就是我的用法:
LatLngBounds bounds = new LatLngBounds(new LatLng(38.46572222050097, -107.75668023304138),new LatLng(39.913037779499035, -105.88929176695862));
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .addApi(Places.GEO_DATA_API)
            .build();
PendingResult<AutocompletePredictionBuffer> results =
Places.GeoDataApi.getAutocompletePredictions(googleApiClient, "Starbucks", bounds, null);
正在使用的版本:com.google.android.gms:play-services-location:8.3.0
文档:https: //developers.google.com/places/android/autocomplete
google-maps google-places-api google-places android-googleapiclient
自上周末以来,我在使用 Google API“Android Publisher”时遇到内部错误(状态代码:500)。事实上,我不能再创建“编辑”了。
使用的API:
POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/edits
第一步:我可以正确验证自己的身份并获得持有者。第二步:API 始终回答相同的响应:500 / backendError / 遇到内部错误。
使用包名称接收的有效负载:com.decathlon.applicationtest1 或 com.decathlon.applicationtest2
 {
   "response":{
      "config":{
         "url":"https://www.googleapis.com/androidpublisher/v3/applications/com.decathlon.applicationtest2/edits",
         "method":"POST",
         "headers":{
            "x-goog-api-client":"gdcl/3.2.2 gl-node/14.13.0 auth/5.10.1",
            "Accept-Encoding":"gzip",
            "User-Agent":"google-api-nodejs-client/3.2.2 (gzip)",
            "Authorization":"Bearer ya29.c.Ko8B4QdsSkPiK202JiitK9Em_2q9id5VvKim3N1Lq8uS6o97RS6986ZmUsxfrlaXXXXXXXXvBSp5dQEiGRx87zA88JBdMN_fljlwXf0Eu6PH12yFIlKaN-nwggVgYHQX9_PxcFdB1PZxEeIkaWmYZgkQfzVTvUtMhhIUNLXXXXXX",
            "Accept":"application/json"
         }
      "data":{
         "error":{
            "code":500,
            "message":"Internal error encountered.",
            "errors":[
               {
                  "message":"Internal error encountered.",
                  "domain":"global",
                  "reason":"backendError"
               }
            ],
            "status":"INTERNAL"
         }
      }
    [...]
   "code":500,
   "errors":[
      {
         "message":"Internal error encountered.",
         "domain":"global",
         "reason":"backendError"
      }
   ]
}
我使用了包名 com.oxylane.alarmesantivol 或 com.decathlon.vision 并且它工作正常。
谢谢你,
android google-api google-play android-googleapiclient google-play-console
有没有一种不需要 Google Play 服务就可以实现 Google 登录的方法?我知道官方文档说你需要 GPS:
• https://developers.google.com/identity/sign-in/android/start-integrating
但是我也在这里发现了相互矛盾的信息:
•没有 Google Play 服务的 Google Plus 登录
也就是说,使用 Google+ Api 您可以在用户没有 GPS 的情况下实现登录。哪个是真的?从技术上讲,您可以在没有 GPS 的情况下实现登录吗?如果可以的话,对于因任何原因无法下载 GPS 的用户来说,作为后备使用会很好。
android google-play-services google-plus-signin android-googleapiclient google-signin
我正在尝试将我的应用程序连接到Google Play服务以访问Google云端硬盘,但它显示我与statusCode的连接失败SIGN_IN_REQUIRED.
但它似乎就在3天前表现得那样.我也检查了谷歌的开发者控制台.他们可能在API中改变了一些我无法弄清楚的东西.欢迎您的帮助.
我的代码:
/**
 * Create a new file and save it to Drive.
 */
    private void saveFileToDrive(final byte[] data) {
    // Start by creating a new contents, and setting a callback.
    Log.i(TAG, "Creating new contents.");
    //final Bitmap image = mBitmapToSave;
    Drive.DriveApi.newDriveContents(mGoogleApiClient)
            .setResultCallback(new ResultCallback<DriveApi.DriveContentsResult>() {
                @Override
                public void onResult(DriveApi.DriveContentsResult result) {
                    // If the operation was not successful, we cannot do anything
                    // and must
                    // fail.
                    if (!result.getStatus().isSuccess()) {
                        Log.i(TAG, "Failed to create new contents.");
                        return; …android google-api google-api-client google-drive-android-api android-googleapiclient
下面的代码我用于谷歌登录google-services.json.我在app文件夹中添加了文件.我正在使用classpath 'com.google.gms:google-services:2.0.0'在根gradle模块中.我已经在开发者控制台检查了我的包并且它正确了,我添加了SHA1密钥,我keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android在终端上运行命令(我正在使用ubuntu).我已启用Google+ API.我已创建了OAuth许可屏幕和OAuth客户端ID.当我尝试使用google登录时,我会收到以下错误
{statusCode = DEVELOPER_ERROR,resolution = null}
我检查类似的问题,但找不到合适的解决方案.码
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestProfile().requestId()
            .requestEmail().requestScopes(new Scope(Scopes.PLUS_ME))
            .requestScopes(new Scope(Scopes.PLUS_LOGIN))
            .build();
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
    googleButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
    startActivityForResult(signInIntent, RC_SIGN_IN);
    }
    });
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == …android google-login google-plus android-googleapiclient google-developer-tools
我目前正在开发一个应用程序,它必须每五分钟检查一次用户的位置并将坐标发送到服务器.我决定使用Google Play服务中的FusedLocation API而不是普通的旧BitManager API,主要是因为我注意到了LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY优先级,声称提供100米精度等级且电池使用合理,这正是我需要.
在我的例子中,我有一个Activity,其继承结构是:
public class MainActivity extends AppCompatActivity implements
        GoogleApiClient.ConnectionCallbacks,
        GoogleApiClient.OnConnectionFailedListener, LocationListener
并实现相关的回调(onConnected,onConnectionFailed,onConnectionSuspended,onLocationChanged).根据官方文档的建议,我还使用此方法获取了GoogleApiClient的实例:
protected synchronized GoogleApiClient buildGoogleApiClient() {
        return new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API).build();
在onConnected中,我使用启动位置更新
LocationServices.FusedLocationApi.requestLocationUpdates(mApiClient,
                mLocationRequest, this);
...并捕获onLocationChanged()中的更改.
但是,我很快发现位置更新似乎在一段时间后停止了.也许是因为这个方法与Activity生命周期有关,我不确定.无论如何,我试图通过创建一个扩展IntentService并由AlarmManager启动的内部类来解决这个问题.所以在onConnected中,我最终做到了这一点:
AlarmManager alarmMan = (AlarmManager) this
                .getSystemService(Context.ALARM_SERVICE);
        Intent updateIntent = new Intent(this, LocUpService.class);
        PendingIntent pIntent = PendingIntent.getService(this, 0, updateIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        alarmMan.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, 0,
                1000 * 60 * 5, pIntent);
LocUpService类如下所示:
public static class LocUpService extends IntentService {
        public LocUpService() {
            super("LocUpService");
        }
        @Override
        protected void onHandleIntent(Intent intent) {
            Coords …