当我的 android 应用使用 intent 尝试 post 时,Instagram 崩溃了

Instagram crashes when my android app trying post on it using intent

我正在为 Android 开发一个应用程序,它应该将图像分享到 Instagram 应用程序。该应用程序打开相机,拍照,然后 Instagram 应用程序打开,"Crop photo" window 处于活动状态。它似乎正在加载图片,但几秒钟后应用程序崩溃了,我看不到图片是否加载。

不明白我哪里错了。

谢谢..!!!

 var intent = Ti.Android.createIntent({
    action: Ti.Android.ACTION_SEND,
    packageName:"com.instagram.android",
    type: "image/*"
});

intent.putExtraUri(intent.EXTRA_STREAM,MediaPath);
intent.putExtra(Ti.Android.EXTRA_TEXT, "Posting via My Andorid App... Testing");
intent.FLAG_ACTIVITY_CLEAR_TOP;
Ti.Android.currentActivity.startActivity(intent);

我认为你应该使用我已经在我的代码中实现的代码:

String type = "image/*";
String filename = "/myPhoto.jpg";
String mediaPath = Environment.getExternalStorageDirectory() + filename;

并调用方法打开 Instagram。

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 官方网站以分享图片和视频,了解更多信息 here。 享受你的代码:)