1
我的問題是這樣的:Android的開發:我如何共享標記的我放在谷歌地圖V2位置
我如何可以共享一個標記,我把通過觸摸位置在地圖上的位置(谷歌地圖V2)我有一個信息窗口,可以看到經緯度。我試圖在地圖上設置一個按鈕來發送放置標記的位置,但我無法使其工作。
請幫我解決這個問題。
這裏是我使用的代碼邏輯:
public void setSendButton(Button sendButton) {
sendButton = (Button) findViewById(R.layout.mymap);}
public void onClick(View v, String Location) {
Context context = getApplicationContext();
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
if (googleMap.getMyLocation() != null) {
googleMap.getMyLocation();
}
Intent i = new Intent(android.content.Intent.ACTION_SEND);
Location = location.getLatitude()/1E6 + "," + location.getLongitude()/1E6;
i.setType("text/plain");
i.putExtra(Intent.EXTRA_SUBJECT, settings.getString("message_subject", getString(R.string.share_location_subject)));
i.putExtra(Intent.EXTRA_TEXT, settings.getString("message_body", getString(R.string.share_location_body))
+ " http://maps.google.com/maps?q=loc:"
+ location);
try {
startActivity(Intent.createChooser(i, getString(R.string.share_title)));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(context, getString(R.string.no_way_to_share), Toast.LENGTH_LONG).show();
}
「我只是不能得到它的工作」 - 這不是一個有用的描述你的症狀。請解釋什麼不是「工作」。例如,你的應用程序崩潰了嗎?如果是這樣,在哪裏,什麼是堆棧跟蹤? – CommonsWare
它不會崩潰。我按下發送按鈕,沒有任何反應。 – Mike
你的代碼將響應按鈕點擊的位置在哪裏?您在這裏使用的'onClick()'方法不會被直接使用,所以大概您正在做其他事情來響應該點擊事件。 – CommonsWare