2017-11-27 4 views
-3

私はさまざまなソーシャルプラットフォーム上で複数の写真を共有するデモに取り組んでいます。 Instagramのコードを使用して1枚の写真を投稿することはできましたが、複数の画像を投稿する方法がわかりません。 Instagramがそのような機能を提供しているかどうかはわかりません。プログラムでインスタントグラムに複数の写真を投稿するにはどうすればいいですか?

答えて

0

はあなたがIntent.ACTION_SEND_MULTIPLEを使用する必要があります。この

ArrayList<Uri> images = new ArrayList<Uri>(); 
Files[] imagesFiles; //your imagesFile 

for(String path : imagesFiles) { 
File file = new File(path); 
Uri uri = Uri.fromFile(file); 
files.add(uri); 
} 

Intent intent = new Intent(); 
intent.setAction(Intent.ACTION_SEND_MULTIPLE); 
intent.putExtra(Intent.EXTRA_SUBJECT, images); 
intent.setType("image/jpeg"); 
0

のように試してみてください。

Intent intent = new Intent(); 
intent.setAction(Intent.ACTION_SEND_MULTIPLE); 
intent.putExtra(Intent.EXTRA_SUBJECT, "Here are some files."); 
intent.setType("image/jpeg"); /* This example is sharing jpeg images. */ 
intent.setPackage("com.instagram.android"); 

ArrayList<Uri> files = new ArrayList<Uri>(); 

for(String path : filesToSend /* List of the files you want to send */) { 
    File file = new File(path); 
    Uri uri = Uri.fromFile(file); 
    files.add(uri); 
} 

intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files); 
startActivity(intent); 

これは間違いなく単純化できましたが、必要な各手順を細かくするためにいくつかの行を残しました。

注::API24から始めると、ファイルURIを共有するとFileUriExposedExceptionが発生します。 compileSdkVersionを23以下に変更するか、content URIs with a FileProviderを使用することができます。

+0

android.content.ActivityNotFoundException:インテントを処理するためのアクティビティが見つかりません{act = android.intent.action.SEND_MULTIPLE typ = image/jpeg flg = 0x1 pkg = com.instagram.android clip = {image/jpeg U:content: //whatsappsharedemo.com.whatysappsharedemo.provider/external_files/Download/Image1.jpg ...}(エクストラがあります)} Not Working –

+0

intent.setPackage( "com.instagram.android")のパッケージ名は何ですか? ? – RBK

+0

はそのデバイスにinstagramがインストールされていますか? – RBK

関連する問題