首页 > 解决方案 > 如何通过 Android 应用在 Facebook 上分享我的位置?

问题描述

我想通过我的 Kotlin 应用在 Facebook 上分享/发布我的位置。有可能的?我已经知道可以与以下人员共享内容(链接、图像和文本):

startActivity(Intent.createChooser(shareIntent, "分享链接使用"))

但实际上我想发布我的位置。谢谢。

标签: androidfacebookkotlin

解决方案


在此处输入图像描述你可以试试这个:这是java在你粘贴代码时会自动转换为kotlin。

String uri = "http://maps.google.com/maps?saddr=" +loc.getLatitude()+","+loc.getLongitude();
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "my location");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, uri);
startActivity(Intent.createChooser(sharingIntent, "Share with:"));

推荐阅读