Android 通过intent发送位图图像和ImageView
我正在开发一个应用程序,我想在其中发送地图位置,如whats应用程序。在我的应用程序中,我正在拍摄需要共享到whats应用程序的地图快照。我可以拍摄快照并通过将其与图像视图设置为测试来进行测试。但是我无法将其共享到whats应用程序,我也创建了uri。但它不起作用。请帮助我执行此操作Android 通过intent发送位图图像和ImageView,android,google-maps,android-intent,bitmap,uri,Android,Google Maps,Android Intent,Bitmap,Uri,我正在开发一个应用程序,我想在其中发送地图位置,如whats应用程序。在我的应用程序中,我正在拍摄需要共享到whats应用程序的地图快照。我可以拍摄快照并通过将其与图像视图设置为测试来进行测试。但是我无法将其共享到whats应用程序,我也创建了uri。但它不起作用。请帮助我执行此操作 @Override public void onClick(View view) { // TODO Auto-generated method stub switch (v
@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
任何人请帮我发送我通过intent拍摄的地图快照,以便与大家分享。如果您尝试将图像转换为字节格式,则可以通过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);
给出一个错误字节[]无法转换为android.os.Parcelable。是否有任何方法可以使用位图图像创建Uri,将其作为shareIntent.putExtra(Intent.EXTRA_STREAM,Uri)传递;如何将位图图像存储到内部存储器中,并在函数结束后获取特定存储的图像并删除。如果有示例代码,请给我