0
我可以打開的twitter(官方客戶端,我不與其他客戶端探測)意圖,我可以共享圖像...只有一個圖像分享倍數通過意向
但在這一刻與Twitter的可能與Twitter圖片在推文中發佈更多圖片(最多= 4)。
這是我的代碼:
public void twitter_intent() {
Intent i = findTwitterClient();
File file1 = new File(Environment.getExternalStorageDirectory() + File.separator + "photo1.png");
File file2 = new File(Environment.getExternalStorageDirectory() + File.separator + "photo2.png");
String mensaje = cxt.getResources().getString(R.string.promocionar_twitter_mensaje,
cxt.getResources().getString(R.string.network_URL_MYWEB));
if (file1.exists())
i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file1));
if (file2.exists())
i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file2));
i.putExtra(Intent.EXTRA_TEXT, mensaje);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
cxt.startActivity(i);
}
private Intent findTwitterClient() {
final String[] twitterApps = {
// package // name - nb installs (thousands)
"com.twitter.android", // official - 10 000
"com.twidroid", // twidroyd - 5 000
"com.handmark.tweetcaster", // Tweecaster - 5 000
"com.thedeck.android" // TweetDeck - 5 000
};
Intent tweetIntent = new Intent(Intent.ACTION_SEND);
tweetIntent.setType("image/png");
final PackageManager packageManager = cxt.getPackageManager();
List<ResolveInfo> list = packageManager.queryIntentActivities(tweetIntent, PackageManager.MATCH_DEFAULT_ONLY);
for (int i = 0; i < twitterApps.length; i++) {
for (ResolveInfo resolveInfo : list) {
String p = resolveInfo.activityInfo.packageName;
if (p != null && p.startsWith(twitterApps[i])) {
tweetIntent.setPackage(p);
return tweetIntent;
}
}
}
return null;
}
第二個文件(照片2)覆蓋第一個。
我怎樣才能把一個URI多個文件?我認爲這樣做會解決問題。
對不起,我的英語...
答案與問題無關。 –