How to send a photo to Instagram using my Android app?

前端 未结 3 1082
死守一世寂寞
死守一世寂寞 2020-12-28 09:46

My app takes photos and I want to share it on Instagram.

My app save the image in this directory

File storagePath = new File(Environment.getExternalS         


        
3条回答
  •  生来不讨喜
    2020-12-28 09:55

    put this code in your button click listener it will redirect you into app and make sure your device have installed Instagram app.

    String type = "image/*";
    imageview.buildDrawingCache();
    Bitmap bmap = imageview.getDrawingCache();
    Uri bmpUri = getLocalBitmapUri(bmap);
    Intent share = new Intent(Intent.ACTION_SEND);
    if (Utils.isPackageExisted(this,"com.instagram.android")) {
     share.setPackage("com.instagram.android");
    }
    share.setType(type);
    share.putExtra(Intent.EXTRA_STREAM, bmpUri);
    startActivity(Intent.createChooser(share, "Share to"));
    

提交回复
热议问题