2017-02-11 16 views
-1

これは、ボタンを押したときに同じチャットアプリケーション内の他の人にリンクを送信するために使用したコードです。ボタンを押したときにGoogleマップURLとして現在地を取得

ボタンを押すと、同じチャットアプリでGoogleマップの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()); 
+0

でこれらの権限を追加し、この

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. } }); 

を試してみてください –

+0

あなたはこれを試すことができますhttps://github.com/akhgupta/Android-EasyLocation – Akhil

答えて

0

私たちは、あなたの質問に[MCVE]を表示してくださいどのような `mChatApplication`がある...知らないあなたのマニフェスト

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

こんにちはハサン...私はすでにこのコードを試しましたが、私の問題は、私が渡す必要がある私のアプリでボタンを押したときです同じアプリ内の他のユーザーとのリンクとしての現在の場所(リンクを共有したり、SMS経由で送信したりしないでください)。 –

+0

あなたはディープリンクについて話していますか –

関連する問題