我基本上寻找的是从另一个应用程序打开 Instagram 应用程序并发送带有标题的图像。
有一些有用的文档可以在 iOS 中执行此操作。 (iPhone 挂钩 https://instagram.com/developer/mobile-sharing/iphone-hooks/)
Instagram 是否支持在 Android 中执行自定义操作(如 iOS 中所述)iPhone 挂钩 https://instagram.com/developer/mobile-sharing/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);
and,
shareIntent.setType("image/jpeg");
shareIntent.setType("image/*");
shareIntent.setType("*/*");
也是,但以上方法都不起作用。