本文介绍了地理codeR的是present()方法总是返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个简单的活动,以测试地理codeR presence,调用地理coder.is present()总是返回false。

类:

 公共类LocationTestActivity延伸活动{

    @覆盖
    公共无效的onCreate(包savedInstanceState){

        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);

        LocationManager locationManager =(LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
        Log.d(LocationTestActivity,地理coder.is present:+经纬度coder.is present());

    }
}
 


AndroidManifest.xml中也有应用程序元素之前,输入以下内容:

 <使用-SDK安卓的minSdkVersion =14机器人:targetSdkVersion =14/>
<使用-权限的Andr​​oid:名称=android.permission.INTERNET对/>
<使用-权限的Andr​​oid:名称=android.permission.ACCESS_FINE_LOCATION/>
 


环境:Eclipse的靛蓝3.7.1 ICS 4.0模拟器在XP专业版2002 SP 3

请帮助我了解:
1.为什么地球coder.is present()总是returing假?
2.什么样的变化,使使地理coder.is present()返回true?

感谢很多提前!

解决方案

其实的需要在后台由框架运行的服务。

从文档:

因此​​,如果我们看一下的,它指出。

注意:记住是present()不可用在pre-API 9 plateforms

I had written a simple Activity to test presence of Geocoder, calling Geocoder.isPresent() always returns false.

Class:

public class LocationTestActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        LocationManager locationManager = (LocationManager)  this.getSystemService(Context.LOCATION_SERVICE);
        Log.d( "LocationTestActivity", "Geocoder.isPresent : " + Geocoder.isPresent() );

    }
}


AndroidManifest.xml ALSO has following entries before "application" element:

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>


Environment : Eclipse Indigo 3.7.1, ICS 4.0 emulator on XP Professional 2002 SP 3

Please help me understand:
1. Why Geocoder.isPresent() is always returing false?
2. What changes to make so that Geocoder.isPresent() returns true?

Thanks much in advance!

解决方案

Actually the Geocoder need a Service running in the background by the framework.

From the documentation:

so if we look at the documentation of isPresent(), it states.

Note: keep in mind that isPresent() is not available in Pre-Api 9 plateforms.

这篇关于地理codeR的是present()方法总是返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 11:32