2013-08-03 71 views
0

我在我的應用程序中創建了一個位圖,並且希望通過電子郵件應用程序或Facebook使用Intent.ACTION_SEND分享它。 共享窗口打開,gmail和yahoomail應用程序圖標出現,但沒有臉譜或g +!我真的不知道有什麼問題。還有一個問題,gmail應用程序無法附加文件(從位圖創建)。我讀了一些類似的問題,但仍然存貨。請幫幫我。Facebook嘗試共享圖像時未出現在共享窗口中

這裏是我的代碼共享:

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")); 
} 

回答

0

後,糾正我的錯誤幼稚(見問題編輯部分),並使用this代碼片段,我終於解決了這個問題。

如果有人知道使用contentValue和我的方法之間的區別是什麼,請與我分享。

+0

幫我在這裏http://stackoverflow.com/questions/31847086/how-to-attach-jpg-or-png-file-to-gmail-or-facebook – Aditya