本文介绍了混得当前的位置空对三星Galaxy Android的大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试运行我对三星Galaxy大,但它的应用没有显示我的当前位置。

 的LocationManager =(的LocationManager)getSystemService(Context.LOCATION_SERVICE);    //创建一个标准的对象来检索提供商
    标准标准=新标准();    //获得最佳供应商的名称
    字符串提供商= locationManager.getBestProvider(标准,真正的);    的System.out.println(提供者=>中+供应商);    //获取当前位置
    地点= locationManager.getLastKnownLocation(供应商);
    的System.out.println(所在地+位置);

但始终这行返回NULL locationManager.getLastKnownLocation(供应商); ,但这个程序正常工作在其他手机一样的索尼和LG电子

我有尝试这么多的链接,但还是同样的问题。

getLastKnownLocation()始终返回null,所有的提供者DummyLocationProvider

Android LocationManager.getLastKnownLocation()返回null

Network供应商和供应商GPS返回空值

许可

 <许可
    机器人:名字=xx.xxx.xxx.permission.MAPS_RECEIVE
    安卓的ProtectionLevel =签名/><使用许可权的android:NAME =android.permission.ACCESS_NETWORK_STATE/>
<使用许可权的android:NAME =xicom.biz.perdiem.permission.MAPS_RECEIVE/>
<使用许可权的android:NAME =android.permission.INTERNET对/>
<使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/>
<使用许可权的android:NAME =com.google.android.providers.gsf.permission.READ_GSERVICES/>
<使用许可权的android:NAME =android.permission.ACCESS_COARSE_LOCATION/>
<使用许可权的android:NAME =android.permission.ACCESS_FINE_LOCATION/>
<使用许可权的android:NAME =android.permission.WRITE_INTERNAL_STORAG​​E/>
<用途特征
    机器人:glEsVersion =0x00020000
    机器人:要求=真/><应用机器人:标签=@字符串/ APP_NAME>
    &所述;元数据
        机器人:名字=com.google.android.maps.v2.API_KEY
        机器人:值=AIzaSyccccccccbvxcbpmFLAZwalBGM/>
......


解决方案

检查this答案,简称

要编程启动您的当前位置运行以下code你打电话之前应用 getLastKnownLocation

  YO​​UR_APPLICATION_CONTEXT.getLocationManager()。requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,0,0,新LocationListener的(){
    @覆盖
    公共无效onStatusChanged(字符串提供商,INT地位,捆绑演员){
    }
    @覆盖
    公共无效onProviderEnabled(字符串提供商){
    }
    @覆盖
    公共无效onProviderDisabled(字符串提供商){
    }
    @覆盖
    公共无效onLocationChanged(决赛地点){
    }
});

固定GPSTracker问题的一些建议可能是,将其设置为1分钟1米

 私有静态最后长MIN_DISTANCE_CHANGE_FOR_UPDATES = 1;
私有静态最后长MIN_TIME_BW_UPDATES = 1000 * 60;

I'm try to run my app on Samsung Galaxy Grand but its not showing my current location.

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    // Creating a criteria object to retrieve provider
    Criteria criteria = new Criteria();

    // Getting the name of the best provider
    String provider = locationManager.getBestProvider(criteria, true);

    System.out.println("provider => " + provider);

    // Getting Current Location
    Location location = locationManager.getLastKnownLocation(provider);
    System.out.println("location  " + location);

but always this line return null locationManager.getLastKnownLocation(provider); but this app works fine in other phones like sony and lg.

i have try so many link but still same problem.

getLastKnownLocation() always returning null, all providers are DummyLocationProvider

Android LocationManager.getLastKnownLocation() returns null

Network provider and GPS provider returning null values

permission

<permission
    android:name="xx.xxx.xxx.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="xicom.biz.perdiem.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />


<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<application android:label="@string/app_name" >
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyccccccccbvxcbpmFLAZwalBGM" />
......
解决方案

Check this for the answer, for short

To programmatically kick start your app for "current location" run the following code before you call getLastKnownLocation

YOUR_APPLICATION_CONTEXT.getLocationManager().requestLocationUpdates(
LocationManager.NETWORK_PROVIDER, 0, 0, new LocationListener() {
    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
    }
    @Override
    public void onProviderEnabled(String provider) {
    }
    @Override
    public void onProviderDisabled(String provider) {
    }
    @Override
    public void onLocationChanged(final Location location) {
    }
});

Some recommendations for fixing GPSTracker issues may be, to set it as 1 min 1 meter

private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 1;
private static final long MIN_TIME_BW_UPDATES = 1000 * 60 ;

这篇关于混得当前的位置空对三星Galaxy Android的大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 00:47