2013-11-15 27 views

回答

2

是的,你可以給這個代碼試試看

try { 
    Intent shareIntent = new Intent(Intent.ACTION_SEND); 
    Uri phototUri = Uri.parse("file:///sdcard/Pictures/yourimage.png"); 
    shareIntent.setType("image/png"); 
    shareIntent.putExtra(Intent.EXTRA_STREAM, phototUri); 
    shareIntent.setClassName("com.twitter.android","com.twitter.android.PostActivity"); 
    startActivity(Intent.createChooser(shareIntent, "Share Image")); 
} catch (Exception e) { 
    Intent i = new Intent(); 
    i.putExtra(Intent.EXTRA_TEXT, message); 
    i.setAction(Intent.ACTION_VIEW); 
    i.setData(Uri.parse("https://mobile.twitter.com/compose/tweet")); 
    startActivity(i); 
} 
+0

謝謝,我已經試過了。但我只想在Twitter上分享。這將彈出所有的分享選項! –

+0

檢查我的編輯。嘗試添加className – Neil

+0

謝謝!我會嘗試這個! –

相關問題