具有共享意图的共享位置活动>>

问题描述 投票:10回答:3

我需要使用共享意图活动从我的应用程序共享位置,我已经看过一些示例,并且知道如何实现共享意图。但是我被困在setType上。我需要我的应用程序共享位置详细信息以及用户在地图上的位置。

通过我复制带有非常相似的问题“无犯罪”的用户代码的方式

任何帮助将不胜感激。

Intent intent1 = new Intent(Intent.ACTION_SEND); 
intent1.setType("text/plain"); 
intent1.putExtra(Intent.EXTRA_TEXT, "The status update text"); 
startActivity(Intent.createChooser(intent1, "Select prefered Service")); 

我需要使用共享意图活动从我的应用程序共享位置,我已经看过一些示例,并且知道如何实现共享意图。但是我被困在setType上。我需要我的申请才能...

android android-intent android-location
3个回答
10
投票

这里是向位置发射意图的代码:


8
投票
Double latitude = user_loc.getLatitude();
Double longitude = user_loc.getLongitude();

String uri = "http://maps.google.com/maps?saddr=" +latitude+","+longitude;

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String ShareSub = "Here is my location";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, ShareSub);
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, uri);
startActivity(Intent.createChooser(sharingIntent, "Share via"));

0
投票
    String uri = "https://www.google.com/maps/?q=" + latitude+ "," +longitude ;
    Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
    sharingIntent.setType("text/plain");
    sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,  uri);
    startActivity(Intent.createChooser(sharingIntent, "Share in..."));
© www.soinside.com 2019 - 2024. All rights reserved.