如何将共享位置从 Google 地图存储到 TextView/String?
How can I store shared Location from Google Maps to a TextView/String?
目前正在创建一个为体育比赛创建事件的应用程序 - 时间、日期、位置等。我有一个按钮可以打开 Google 地图并添加 "android.intent.action.SEND" 我可能能够将位置从地图共享到我的应用程序,但是我不知道如何从地图中提取 long/lat 或 url 并将其存储在字符串或 TextView/EditText 中。
我该怎么做?
我已经创建了 TextView、EditTexts 和变量。分享到我的应用只是重置它。
//From Manifest
<intent-filter>
<action android:name="android.intent.action.SEND"></action>
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
//Button to Open Google Maps
locationPicker.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Uri gmmIntentUri = Uri.parse("geo:0,0?q=");
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager managerclock = getPackageManager();
i = managerclock.getLaunchIntentForPackage("com.google.android.apps.maps");
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
}
});
从 Google 地图共享时,url 或 longitude/latitude 将存储在变量中或设置为我可以共享的 TextView。
没有通过 intent
从 Google 地图获取位置的经典方法(例如从相机获取照片)。
Google Maps Place Picker API 本来可以为您解决这个问题,但现在 已弃用。由于某些原因,它将于 2019 年 7 月 29 日停用。
您必须为此任务选择一个不同的Google Maps API
。 Google 做了一个 API Picker 来帮助你挑选你想要的。看看吧。
恐怕您必须重新设计用户在您的应用中选择位置的方式。一种方法是创建一个 activity,其中包含 Google 地图。
目前正在创建一个为体育比赛创建事件的应用程序 - 时间、日期、位置等。我有一个按钮可以打开 Google 地图并添加 "android.intent.action.SEND" 我可能能够将位置从地图共享到我的应用程序,但是我不知道如何从地图中提取 long/lat 或 url 并将其存储在字符串或 TextView/EditText 中。 我该怎么做?
我已经创建了 TextView、EditTexts 和变量。分享到我的应用只是重置它。
//From Manifest
<intent-filter>
<action android:name="android.intent.action.SEND"></action>
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
//Button to Open Google Maps
locationPicker.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Uri gmmIntentUri = Uri.parse("geo:0,0?q=");
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager managerclock = getPackageManager();
i = managerclock.getLaunchIntentForPackage("com.google.android.apps.maps");
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
}
});
从 Google 地图共享时,url 或 longitude/latitude 将存储在变量中或设置为我可以共享的 TextView。
没有通过 intent
从 Google 地图获取位置的经典方法(例如从相机获取照片)。
Google Maps Place Picker API 本来可以为您解决这个问题,但现在 已弃用。由于某些原因,它将于 2019 年 7 月 29 日停用。
您必须为此任务选择一个不同的Google Maps API
。 Google 做了一个 API Picker 来帮助你挑选你想要的。看看吧。
恐怕您必须重新设计用户在您的应用中选择位置的方式。一种方法是创建一个 activity,其中包含 Google 地图。