谷歌地图应用程序崩溃的棒棒堂机器人 [英] Google Map Application Crashing in Lollipop android

查看:166
本文介绍了谷歌地图应用程序崩溃的棒棒堂机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现谷歌地图API V2在我的Andr​​oid应用程序。该应用程序适用于所有设备的罚款,但不是在棒棒糖设备。应用程序崩溃的棒棒糖。我没有搜索这个问题,但没有得到一个合理的解决方案。如果有任何人知道这个问题,请大家帮忙me.I'll是非常感激的。

I am implementing Google map API v2 in my android application. The application works fine in all devices but not in lollipop devices. Application is crashing in lollipop. I did search for this problem but didn't get a reasonable solution. If any one knows about this problem please help me.I'll be very thankful

推荐答案

可能是你正在尝试通过获得的位置 LocationManager 类。这样完美的作品preLollipop设备上。但是,在棒棒糖它亘古不变的作品。现在,再次谷歌已经发布了一个新的API,但他们还没有更新的文档正常。这里有一个地点演示code,将提供您使用新的/最新位置服务API一定的时间间隔后得到位置对象。

May be you are trying to get location via LocationManager class. This way perfectly works on preLollipop device. But in lollipop it doesnot works. Now Again Google has released a new API but they haven't updated the documentation properly. Here has a location get demo code that will provide you to get Location Object after a certain interval using the new/latest Location Service API.

import android.app.Activity;
import android.location.Location;
import android.os.Bundle;
import android.util.Log;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;

/**
 * Created by skarim on 10/29/15.
 */
public class GetLocationAfterCertainInterval extends Activity implements  GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener ,
        LocationListener {
    GoogleApiClient apiClient=null;
    LocationRequest mLocationRequest=null;
    private int locationInterval,fastedInterval;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Initialize Your View here.
        setLocationLocationRequest();
    }

    @Override
    public void onDestroy() {
        // Your need of location update is done. So you have to stop the apiClient.
        super.onDestroy();
        this.apiClient.disconnect();
    }


    private void setLocationLocationRequest() {

        try {
            apiClient=new GoogleApiClient.Builder(this).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(LocationServices.API).build();

            mLocationRequest = new LocationRequest();
            mLocationRequest.setInterval(29000);
            mLocationRequest.setFastestInterval(5000);
            mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
            apiClient.connect();

        }catch (Exception e){
            Log.d("LS", e.getMessage() == null ? "" : e.getMessage());
        }

    }
    @Override
    public void onConnected(Bundle bundle) {
        // Your API Client is connected. So can request for updates
        LocationServices.FusedLocationApi.requestLocationUpdates(apiClient, mLocationRequest, this);
    }

    @Override
    public void onConnectionSuspended(int i) {

    }

    @Override
    public void onLocationChanged(Location location) {
        // After your desired interval This api will give you the Location Object.

    }

    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) {

    }


}

有关这个API,你可以看到的这个开发链接

For more details about this API you can see this Developer Link

我的相关答案就在这里

抱歉坏English.Thanks

Sorry for bad English.Thanks

这篇关于谷歌地图应用程序崩溃的棒棒堂机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆