共享文本,我需要共享文本到Instagram的,但我不能使用Android如何在Instagram的
intent.putExtra(Intent.EXTRA_TEXT,"MY TEXT");
沒有發生那樣的情況幫我做這件事
共享文本,我需要共享文本到Instagram的,但我不能使用Android如何在Instagram的
intent.putExtra(Intent.EXTRA_TEXT,"MY TEXT");
沒有發生那樣的情況幫我做這件事
通用代碼與任何社會共享文本應用:
第一步:獲取應用程序,你想分享的包名:
要獲得軟件包名稱使用adb logcat -s ActivityManager
這個命令在Windows中運行應用程序,例如你想要包名稱的Instagram所以運行上面的命令和打開instagram應用程序,你會得到在日誌中的包名稱 注意:上面列出的adb命令是用於Windows。 對於ubntu可以使用adb logcat | grep "ActivityManager"
第2步:一旦你得到了應用的應用包名稱下方是用於共享文本通用代碼。
try {
Intent shareOnAppIntent = new Intent();
shareOnAppIntent .setAction(Intent.ACTION_SEND);
shareOnAppIntent .putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.share_body));
shareOnAppIntent .setType("text/plain");
shareOnAppIntent .setPackage(PACKAGE_NAME_OF_APP);
startActivity(shareOnAppIntent);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(ShareAppActivity.this, "APP is not installed", Toast.LENGTH_LONG).show();
}
這是在Instagram中分享圖像和文字的意圖代碼。
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_STREAM,uri);
shareIntent.putExtra(Intent.EXTRA_TEXT,"YOUR TEXT TO SHARE IN INSTAGRAM");
shareIntent.setPackage("com.instagram.android");
return shareIntent;
不幸的是,Instagram沒有收到意向文本。它只接收EXTRA_STREAM對象。您只能共享jpeg,gif,png格式的圖片。由於他們沒有提供任何SDK,你不能以任何其他方式共享。
請Instagram的開發者文檔here他們明確提的是,接受意圖參數爲EXTRA_STREAM
這是已停止接受預填充capitions爲在Instagram的
String type = "image/*";
String filename = "/myPhoto.jpg";
String mediaPath = Environment.getExternalStorageDirectory() + filename;
createInstagramIntent(type, mediaPath);
private void createInstagramIntent(String type, String mediaPath){
// Create the new Intent using the 'Send' action.
Intent share = new Intent(Intent.ACTION_SEND);
// Set the MIME type
share.setType(type);
// Create the URI from the media
File media = new File(mediaPath);
Uri uri = Uri.fromFile(media);
// Add the URI to the Intent.
share.putExtra(Intent.EXTRA_STREAM, uri);
// Broadcast the Intent.
startActivity(Intent.createChooser(share, "Share to"));
}
的Instagram分享照片的代碼提高系統內容的質量。看到這篇文章。
http://developers.instagram.com/post/125972775561/removing-pre-filled-captions-from-mobile-sharing
post後綴intent code for instagram – KOTIOS