谷歌地图应用程序崩溃在棒棒糖android

问题描述:

我在我的android应用程序中实现谷歌地图API v2。该应用程序在所有设备上都能正常工作,但不适用于棒棒糖设备。应用程序崩溃在棒棒糖。我没有搜索这个问题,但没有得到一个合理的解决方案。如果有人知道这个问题,请帮助我。我会非常感谢谷歌地图应用程序崩溃在棒棒糖android

+0

添加您的logcat这里.. !! – AndiGeeky

+0

请显示您的日志 –

+0

对不起,我没有5.0的设备来调试代码。我正在4.4.4上测试它,它的工作正常。但我的客户端5.0,当他测试应用程序,然后应用程序崩溃 –

尝试使用Android Studio生成Google地图活动。

+0

对不起,我没有得到你 –

+0

阅读步骤3 https://developers.google.com/maps/documentation/android-api/start – phuanh004

可能是您正在尝试通过 LocationManager类获取位置。这种方式完美地适用于preLollipop设备。但是在棒棒糖中它不起作用。现在再次谷歌发布了一个新的API,但他们没有正确地更新文档。这里有一个获取演示代码的位置,可以让您在使用新的/最新的位置服务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的更多详细信息,你可以看到this Developer Link

我的相关Answer is here

对不起坏English.Thanks