<tfoot id='TJ1qa'></tfoot>

    <legend id='TJ1qa'><style id='TJ1qa'><dir id='TJ1qa'><q id='TJ1qa'></q></dir></style></legend>

    <small id='TJ1qa'></small><noframes id='TJ1qa'>

    <i id='TJ1qa'><tr id='TJ1qa'><dt id='TJ1qa'><q id='TJ1qa'><span id='TJ1qa'><b id='TJ1qa'><form id='TJ1qa'><ins id='TJ1qa'></ins><ul id='TJ1qa'></ul><sub id='TJ1qa'></sub></form><legend id='TJ1qa'></legend><bdo id='TJ1qa'><pre id='TJ1qa'><center id='TJ1qa'></center></pre></bdo></b><th id='TJ1qa'></th></span></q></dt></tr></i><div id='TJ1qa'><tfoot id='TJ1qa'></tfoot><dl id='TJ1qa'><fieldset id='TJ1qa'></fieldset></dl></div>

      <bdo id='TJ1qa'></bdo><ul id='TJ1qa'></ul>

      网络位置提供商不提供位置 android

      时间:2023-09-02

          <i id='kkfQW'><tr id='kkfQW'><dt id='kkfQW'><q id='kkfQW'><span id='kkfQW'><b id='kkfQW'><form id='kkfQW'><ins id='kkfQW'></ins><ul id='kkfQW'></ul><sub id='kkfQW'></sub></form><legend id='kkfQW'></legend><bdo id='kkfQW'><pre id='kkfQW'><center id='kkfQW'></center></pre></bdo></b><th id='kkfQW'></th></span></q></dt></tr></i><div id='kkfQW'><tfoot id='kkfQW'></tfoot><dl id='kkfQW'><fieldset id='kkfQW'></fieldset></dl></div>
        • <tfoot id='kkfQW'></tfoot>

          1. <small id='kkfQW'></small><noframes id='kkfQW'>

              <bdo id='kkfQW'></bdo><ul id='kkfQW'></ul>
                  <tbody id='kkfQW'></tbody>
              1. <legend id='kkfQW'><style id='kkfQW'><dir id='kkfQW'><q id='kkfQW'></q></dir></style></legend>
                本文介绍了网络位置提供商不提供位置 android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在开发一个小型 android 应用程序,我想在其中使用网络提供商找出用户的当前位置.我通过以下方式尝试了这个,但它没有给我任何输出:

                I am developing a small android application in which I want to find out the user's current location by using the network provider. I tried this in following ways but it's not giving me any output :

                networklocationManager = (LocationManager) this
                        .getSystemService(Context.LOCATION_SERVICE);
                // Define a listener that responds to location updates
                LocationListener networklocationListener = new LocationListener() {
                
                    public void onLocationChanged(Location location) {
                        Log.i("********************************",
                                "this is my network location " + location);
                        String Location_text = "NETWORK LOCATION latitude:"
                                + location.getLatitude() + " longitude:"
                                + location.getLatitude();
                        network_location.setText(Location_text);
                    }
                
                    public void onStatusChanged(String provider, int status,
                            Bundle extras) {}
                
                    public void onProviderEnabled(String provider) {}
                
                    public void onProviderDisabled(String provider) {}
                };
                // Register the listener with the Location Manager to receive location
                // updates
                networklocationManager
                        .requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                                networklocationListener);
                

                我像这样在清单文件中授予权限

                I gave permissions in my manifest file like this

                 <uses-permission 
                    android:name="android.permission.INTERNET" />
                <uses-permission
                    android:name="android.permission.ACCESS_COARSE_LOCATION" />
                 <uses-permission
                    android:name="android.permission.ACCESS_FINE_LOCATION" /> 
                

                有什么我想念的吗?这是正确的方法吗?需要帮忙.谢谢...

                Is there any thing which I am missing ? Is this the correct way? Need help. Thank you...

                public class MainActivity extends Activity implements LocationListener {
                
                    private TextView latituteField;
                    private TextView longitudeField;
                    private LocationManager gpslocationManager;
                    private LocationManager networklocationManager;
                    private LocationManager networklocationManager1;
                    private String provider;
                    private TextView gps_location;
                    private TextView network_location;
                
                    @Override
                    public void onCreate(Bundle savedInstanceState) {
                        super.onCreate(savedInstanceState);
                        setContentView(R.layout.activity_main);
                        gps_location = (TextView) findViewById(R.id.gps_location);
                        network_location = (TextView) findViewById(R.id.network_location);
                        networkLocation();
                    }
                
                    public void networkLocation() {
                        networklocationManager = (LocationManager) this
                                .getSystemService(Context.LOCATION_SERVICE);
                        LocationListener networklocationListener = new LocationListener() {
                
                            public void onLocationChanged(Location location) {
                                Log.i("********************************",
                                        "this is my network location " + location);
                                String Location_text = "NETWORK LOCATION latitude:"
                                        + location.getLatitude() + " longitude:"
                                        + location.getLatitude();
                                network_location.setText(Location_text);
                            }
                
                            public void onStatusChanged(String provider, int status,
                                    Bundle extras) {}
                
                            public void onProviderEnabled(String provider) {}
                
                            public void onProviderDisabled(String provider) {}
                        };
                        networklocationManager
                                .requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                                        networklocationListener);
                    }
                }
                

                推荐答案

                你的网络供应商启用了吗?

                Is your network provider enabled?

                boolean network_enabled;
                try {
                    network_enabled = locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
                } catch(Exception ex) {
                   ex.printStackTrace();
                }
                

                这篇关于网络位置提供商不提供位置 android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:android上的javascript地理定位不起作用 下一篇:在没有活动的情况下使用 Google 地图位置

                相关文章

                最新文章

                <legend id='v3JoV'><style id='v3JoV'><dir id='v3JoV'><q id='v3JoV'></q></dir></style></legend>
              2. <i id='v3JoV'><tr id='v3JoV'><dt id='v3JoV'><q id='v3JoV'><span id='v3JoV'><b id='v3JoV'><form id='v3JoV'><ins id='v3JoV'></ins><ul id='v3JoV'></ul><sub id='v3JoV'></sub></form><legend id='v3JoV'></legend><bdo id='v3JoV'><pre id='v3JoV'><center id='v3JoV'></center></pre></bdo></b><th id='v3JoV'></th></span></q></dt></tr></i><div id='v3JoV'><tfoot id='v3JoV'></tfoot><dl id='v3JoV'><fieldset id='v3JoV'></fieldset></dl></div>
                  <tfoot id='v3JoV'></tfoot>
                    <bdo id='v3JoV'></bdo><ul id='v3JoV'></ul>
                  1. <small id='v3JoV'></small><noframes id='v3JoV'>