Twitter 共有インテントに画像を追加しようとしています。あるクラスで画像をローカルに保存し、別のクラスで画像を取得して意図にアタッチしようとします。
これが私のコードです
private void shareTwitter(){
try {
FileInputStream fis;
fis = getActivity().openFileInput("photo.jpg");
Bitmap shot = BitmapFactory.decodeStream(fis);
File file = new File(MapView.path, "snapshot.jpg");
if(file.exists()){
Log.i("FILE", "YES");
}else{
Log.i("FILE", "NO");
}
Uri uri = Uri.parse(file.getAbsolutePath());
//Uri uri = Uri.parse("android.resource://com.gobaby.app/drawable/back");
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("/*");
intent.setClassName("com.twitter.android", "com.twitter.android.PostActivity");
intent.putExtra(Intent.EXTRA_TEXT, "Thiws is a share message");
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(intent);
} catch (final ActivityNotFoundException e) {
Toast.makeText(getActivity(), "You don't seem to have twitter installed on this device", Toast.LENGTH_SHORT).show();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
現時点では、logcat に例外はありません。私のアプリは、画像の読み込みに失敗したというトーストを表示するだけです。
私は何を間違っていますか?