我有全屏活动:
public class FullImageActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.full_image);
// get intent data
Intent i = getIntent();
// Selected image id
int position = i.getExtras().getInt("id");
ImageAdapter imageAdapter = new ImageAdapter(this);
ImageView imageView = (ImageView) findViewById(R.id.full_image_view);
imageView.setImageResource(imageAdapter.mThumbIds[position]);
BitmapDrawable bm = (BitmapDrawable) imageView.getDrawable();
Bitmap mysharebmp = bm.getBitmap();
try {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
mysharebmp.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
//you can create a new file name "test.jpeg"
File f = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
+ File.separator + "test.jpeg");
f.createNewFile();
//write the bytes in file
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
// remember close de FileOutput
fo.close();
Log.d("done","done");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + "test.jpeg";
Uri m = Uri.parse(path);
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("image/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, m);
startActivity(Intent.createChooser(sharingIntent,
"Share image using"));
}
}
为什么whatsapp是唯一正在运行的应用程序? 所有其他应用程序都告诉他们失败或无法下载.... 我想与每个应用程序分享,我不知道我做错了什么PLZ帮助我,我打赌你很容易。
Thx dudes!
答案 0 :(得分:0)
关闭 找到了解决方案
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/Pictures/tmp.jpeg"));