【问题标题】:Instagram crashes when my android app trying post on it using intent当我的 android 应用程序尝试使用意图在 Instagram 上发帖时,Instagram 崩溃了
【发布时间】:2015-09-03 05:37:51
【问题描述】:

我正在为 Android 开发一个应用程序,该应用程序应将图像共享到 Instagram 应用程序。该应用程序打开相机,拍照,然后打开 Instagram 应用程序,同时“裁剪照片”窗口处于活动状态。它似乎正在加载图片,但几秒钟后应用程序崩溃了,我看不到图片被加载了。

不明白我哪里出错了。

谢谢..!!!

 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);

【问题讨论】:

  • 这是 Instagram 的问题,不是你的问题
  • 可能是,但是当我直接打开 Instagram 应用程序时它可以工作,但是当我尝试从我的应用程序上传时它崩溃了。有什么解决方案吗?
  • 谢谢,我已向 Instagram 报告问题

标签: android android-intent instagram appcelerator


【解决方案1】:

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

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。 享受你的代码:)

【讨论】:

  • 感谢 Piyush,但是使用我的代码我可以打开 Instagram,但它在几秒钟后崩溃了我无法看到那里的图像.. :(
  • 所以,亲爱的,这不是你的代码问题。它的 instagram 问题。请向他们报告。
  • Instagram 没有任何问题,实际上我犯了一个愚蠢的错误,即传递了错误的图像路径。也改为 intent.putExtraUri(intent.EXTRA_STREAM,MediaPath);我把 intent.putExtraUri(intent.EXTRA_STREAM,""+MediaPath);它的工作原理......!!!上面两个代码都很好:)
猜你喜欢
  • 1970-01-01
  • 2020-02-07
  • 1970-01-01
  • 2022-01-01
  • 1970-01-01
  • 2013-08-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多