Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 按下按钮时获取当前位置作为谷歌地图url_Android_Google Maps_Android Gps - Fatal编程技术网

Android 按下按钮时获取当前位置作为谷歌地图url

Android 按下按钮时获取当前位置作为谷歌地图url,android,google-maps,android-gps,Android,Google Maps,Android Gps,这是我用来在按下按钮时将链接发送给同一聊天应用程序中的其他人的代码 当按下按钮时,如何在同一聊天应用程序中获取当前位置作为谷歌地图url TextView link = (TextView) findViewById(R.id.TextView1); String linkText = "https://www.google.co.in/maps?geo:0,0?q=my+street+address?geo:latitude,longitude"; mChatApplication.newLo

这是我用来在按下按钮时将链接发送给同一聊天应用程序中的其他人的代码

当按下按钮时,如何在同一聊天应用程序中获取当前位置作为谷歌地图url

TextView link = (TextView) findViewById(R.id.TextView1);
String linkText = "https://www.google.co.in/maps?geo:0,0?q=my+street+address?geo:latitude,longitude";
mChatApplication.newLocalUserMessage(linkText);
link.setText(linkText);
link.setMovementMethod(LinkMovementMethod.getInstance());
试试这个

currentLocation = (Button) findViewById(R.id.currentLocation);
    currentLocation.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // instantiate the location manager, note you will need to request permissions in your manifest
            LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            // get the last know location from your location manager.
            if (ActivityCompat.checkSelfPermission(MapsActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
                    ActivityCompat.checkSelfPermission(MapsActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                // TODO: Consider calling
                //    ActivityCompat#requestPermissions
                // here to request the missing permissions, and then overriding
                //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                //                                          int[] grantResults)
                // to handle the case where the user grants the permission. See the documentation
                // for ActivityCompat#requestPermissions for more details.
                return;
            }
            Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

            // now get the lat/lon from the location and do something with it.


        }
    });
在清单中添加这些权限

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


我们不知道什么是
mChatApplication
。。。请用你的问题在a中显示a你可以试试这个Hi Hasan…我已经尝试了这个代码,但我的问题是当我按下应用程序中的按钮时,它应该将当前位置作为链接传递给同一应用程序中的其他人(而不是共享链接或通过短信发送)。你是说深度链接吗