2013-10-10 17 views
4

我基本上找送的圖像從另一個應用中打開Instagram的應用程序,並用字幕發送圖像。 在iOS中有一些有用的文檔可以做到這一點。 (iPhone-hooks打開Instagram的應用程序,並用字幕

是否支持Instagram在iOS中執行自定義操作,如iPhone-hooks中所述?

下面是我的應用程序用於部分執行該任務當前的代碼。

private void sendImageToIntagram(Activity activity) { 
    Intent intent = activity.getPackageManager().getLaunchIntentForPackage("com.instagram.android"); 
    if (intent != null) { 
     Intent shareIntent = new Intent(); 
     shareIntent.setAction(Intent.ACTION_SEND); 
     shareIntent.setPackage("com.instagram.android"); 
     String imagePath = ImageUtil.getProcessedImage().getAbsolutePath(); 
     try { 
      shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(MediaStore.Images.Media.insertImage(activity.getContentResolver(), imagePath, "Title", "Description"))); 
      // shareIntent.putExtra(Intent.EXTRA_TITLE, "Caption 01"); 
      // shareIntent.putExtra(Intent.EXTRA_TEXT, "Caption 02"); 
      // shareIntent.putExtra(Intent.EXTRA_SUBJECT,"Caption 03"); 

     } catch (FileNotFoundException e) { 
      e.printStackTrace(); 
     } 
     shareIntent.setType("image/jpeg"); 
     activity.startActivity(shareIntent); 
    } else { 
     // bring user to the market to download the app. 

     intent = new Intent(Intent.ACTION_VIEW); 
     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
     intent.setData(Uri.parse("market://details?id=" + "com.instagram.android")); 
     activity.startActivity(intent); 
    } 
} 

以上都沒有標題,說明,標題01,標題02,標題03起作用。

然後我用,

shareIntent.setAction(Intent.ACTION_SEND);嘗試 - >shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);

,並

shareIntent.setType("image/jpeg"); 
shareIntent.setType("image/*"); 
shareIntent.setType("*/*"); 

過,但沒有上述還曾。

回答

3

簡短回答,編號爲

Instagram沒有與iPhone掛鉤相同的Android版本。

他們確實支持ACTION_SEND,但他們只考慮了Intent.EXTRA_STREAM

除非發生在過去4個月(我對此表示懷疑),這傢伙把自己的代碼存根,從他們的AndroidManifest.xml你可以設想,通過查看他們的intent catcher活動,他們只關心android.intent.extra.STREAM改變。

所以現在,你可以不大於實際圖像發送任何其他數據。

4

看着this question,特別是Chriskot的this answer,看起來自2014年7月以來,Instagram可以讓你做到這一點。

長話短說

Intent instagram = new Intent(android.content.Intent.ACTION_SEND); 
instagram.setType("image/*"); 
instagram.putExtra(Intent.EXTRA_STREAM, [URI of photo]); 
instagram.putExtra(Intent.EXTRA_TEXT, [Text of caption]); 
instagram.setPackage(instagramPackageName); 
startActivity(instagram); 
相關問題