Search code examples
androidasp.netweb-applicationsinstagraminstagram-api

How i open Instagram in New Post mode?


With all respects, i'm not familiar to Instagram API. But i want to open instagram in new post mode as i said. For example: i think know Instagram downloaders.Insta Downloader

like instadownload. how they open Instagram in new post mode? I want to know it for Web Application and Android Application. So i want to create a page with OpenDialog, Which choose a picture and then redirect to Instagram and land in New Post Mode. Would you please help me in this?


Solution

  • From instagram docs:

    String type = "image/*";
    String filename = "/myPhoto.jpg";
    String mediaPath = Environment.getExternalStorageDirectory() + filename;
    
    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"));
    }