I create a bitmap in my app and want to share it via email apps or Facebook using Intent.ACTION_SEND. the share window opens and gmail and yahoomail apps icon appear but no facebook or g+! I really doesn't know what's the problem. There is another problem that gmail app cannot attach the file (created from bitmap). I read a few similar questions but still I'm stocked. Help me please.
here is my code for sharing:
private static File writePhotoPng(Bitmap data, String pathName) {
File file = new File(pathName);
try {
file.createNewFile();
// BufferedOutputStream os = new BufferedOutputStream(
// new FileOutputStream(file));
FileOutputStream os = new FileOutputStream(file);
data.compress(Bitmap.CompressFormat.PNG, 100, os);
os.flush();
os.close();
} catch (Exception e) {
e.printStackTrace();
}
return file;
}
public static void ShareOnFb(Bitmap share, Activity activity, String emailSubject){
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
// EDIT:
// !!! childish mistake. below line is correct !!! intent.setType("Image/*");
intent.setType("image/*");
//add data to intent, the receiving app will decide what to do with it.
// email subject:
if (emailSubject != null && !emailSubject.equals("")){
intent.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
}
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(writePhotoPng(share, "temp.png")));
activity.startActivity(Intent.createChooser(intent, "Share on"));
}