我正在开发一个应用程序,我想发送地图位置,如什么应用程序。在我的应用程序中,我正在拍摄地图的快照,需要分享给什么应用程序。我可以拍摄快照和测试,通过设置图像视图test.bu我无法分享到什么应用程序,我也创建了uri也。但它不工作请帮我做
@Override
public void onClick(View view) {
// TODO Auto-generated method stub
switch (view.getId()) {
case R.id.watsapp_button:
takeSnapshot();
Uri imgUri=Uri.parse("android.resource://com.koteswara.wise.plaeces/"+R.id.screenimage);
//address = _gettext.getText().toString();
//String uri = Uri.Builder().scheme("geo").appendPath(latitude +","+ longitude).appendQueryParameter("q", result).build();
//String uri = "http://maps.google.com/maps?saddr=" +latitude+","+longitude;
/*String uri = "geo:" + latitude + ","
+longitude + "?q=" + latitude
+ "," + longitude;*/
//Uri imgUri=Uri.parse("android.resource://my.package.name/"+R.drawable.image);
String uri =
"http://maps.google.com/maps?q=" + latitude + "," + latitude + "&iwloc=A";
Uri myUri = Uri.parse(uri);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
//Target whatsapp:
shareIntent.setPackage("com.whatsapp");
//Add text and then Image URI
shareIntent.putExtra(Intent.EXTRA_TEXT, result);
System.out.println(result);
System.out.println(uri);
shareIntent.putExtra(Intent.EXTRA_STREAM, imgUri);
shareIntent.setType("image/*");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
try {
startActivity(shareIntent);
} catch (android.content.ActivityNotFoundException ex) {
//ToastHelper.MakeShortText("Whatsapp have not been installed.");
}
break;
以下代码显示拍摄快照
private void takeSnapshot() {
if (googleMap == null) {
return;
}
final SnapshotReadyCallback callback = new SnapshotReadyCallback() {
@Override
public void onSnapshotReady(Bitmap snapshot) {
// Callback is called from the main thread, so we can modify the ImageView safely.
_snapshot=snapshot;
snapshotHolder.setImageBitmap(snapshot);
System.out.println(snapshotHolder+"snap shot ");
}
};
googleMap.snapshot(callback);
}
below is the image view
snapshotHolder=(ImageView)rootview.findViewById(R.id.screenimage);
Uri imgUri=Uri.parse("android.resource://com.koteswara.wise.plaeces/"+R.id.screenimage);
in the above uri the R.id.screenimage is the id of the imageview i am setting the snap shot of the map-view
任何人请帮我发送地图的快照我通过意图分享与什么应用解决方案将提前赞赏
答案 0 :(得分:1)
您尝试将图像转换为字节格式,然后可以通过Intent的putExtra()方法传递它。
Bitmap snapshot;
ByteArrayOutputStream stream=new ByteArrayOutputStream();
snapshot.compress(Bitmap.CompressFormat.JPEG, 90, stream);
byte[] temp_photo=stream.toByteArray();
Intent shareIntent=new Intent();
shareIntent.putExtra("Image_Key",temp_photo);