很長一段時間的研究。最後我找到了解決辦法..
它對我很好。
private void postToFacebookViaIntent() {
File mFile = new File(Environment.getExternalStorageDirectory()+ "/images.jpg");
Intent shareIntent = findFacebookClient();
if (shareIntent != null && mFile!= null) {
shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(mFile));
startActivity(Intent.createChooser(shareIntent, "Share"));
} else {
Toast.makeText(SharingActivity.this, "Facebook App is not installed", Toast.LENGTH_SHORT).show();
}
}
private Intent findFacebookClient() {
final String twitterApps = "facebook";
Intent facebookIntent = new Intent();
facebookIntent.setAction(Intent.ACTION_SEND);
facebookIntent.setType("image/jpeg");
final PackageManager packageManager = getPackageManager();
List<ResolveInfo> list = packageManager.queryIntentActivities(
facebookIntent, 0);
for (ResolveInfo resolveInfo : list) {
String p = resolveInfo.activityInfo.packageName;
if (p != null && p.contains(twitterApps)) {
facebookIntent.setPackage(p);
return facebookIntent;
}
}
return null;
}
你能否詳細說明 '對話框並不看好'?這樣,任何新的解決方案都可以在你看到它們時克服這些限制。 – 2011-04-17 10:56:59
我相信它顯示在網絡視圖上,非常擁擠,我在畫廊中看到的那個看起來更好。 – rogerstone 2011-04-17 12:43:46