我正尝试使用我的Android应用程序在Instagram上共享图像。但当图像共享完成后,我无法取得成功。 我使用了Intent进程,但是在图像共享完成时,我无法取得成功。如何在Android中完成Instagram共享时获得成功
Intent share = new Intent(Intent.ACTION_SEND);
// Limit this call to instagram
share.setPackage("com.instagram.android");
// Set the MIME type
share.setType("image/jpg");
// Create the URI from the media
File media = new File("/storage/emulated/0/DCIM/Camera/IMG_20170627_222256129_HDR.jpg");
Uri uri = Uri.fromFile(media);
// Add the URI to the Intent.
share.putExtra(Intent.EXTRA_STREAM, uri);
try {
// Fire the Intent.
startActivityForResult(share, REQUEST_CODE);
} catch(ActivityNotFoundException e) {
// instagram not installed
}
已经做到了。当我发布图片时,它不会在应用中返回。 – dev
你能提供你的onActivityResult吗?以防万一。 – Nek
您可以检查THI @覆盖 保护无效onActivityResult(INT requestCode,INT resultCode为,意图数据){ 开关(requestCode){ 情况REQUEST_CODE: 如果(resultCode为== Activity.RESULT_OK){// 你在这里做什么你必须做。 System.out.println(“完成共享...”); } } } – dev