HGO

  • Menu
  • Menu
  • Menu
  • Menu
    • SubMenu1
    • SubMenu2
    • SubMenu3
  • Menu
    • SubMenu1
    • SubMenu2
    • SubMenu3
    • SubMenu4
Home › Android Intents

Android Intents

By Bang HGO Rabu, 20 Maret 2019 Add Comment Edit

Android Intents

If your application creates photos or videos and you would like your users to share them using Instagram, you can use Android Intents to open your media in Instagram's sharing flow.
The examples below create an Implicit Intent which will then prompt the user to select the application they wish to send the media to. When triggered, Instagram will immediately present the user with the crop screen.
Intent Parameter Description
Intent.EXTRA_STREAM media path on device

Sharing an image

Requirement Value
Photo Format jpeg, gif, png
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"));
}

Sharing a video

Requirement Value
Minimum Duration 3 seconds
Maximum Duration 10 minutes
Video Format mkv, mp4
Minimum Dimensions 640x640 pixels
String type = "video/*";
String filename = "/myVideo.mp4";
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"));
}

Share this post

0 Response to "Android Intents"

Posting Komentar

Posting Lebih Baru Posting Lama Beranda
Langganan: Posting Komentar (Atom)

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel

insert_pixel_code_here

Mengenai Saya

Foto saya
Bang HGO
Lihat profil lengkapku

Arsip Blog

  • ▼  2019 (23)
    • ▼  Maret (23)
      • Platform Policy
      • Platform Changelog
      • Developer Support
      • Libraries
      • Android Intents
      • iPhone Hooks
      • Mobile Sharing
      • Embedding
      • Comment Endpoints
      • User Endpoints
      • API Endpoints
      • Secure Requests
      • Sandbox Mode
      • Permissions Review
      • Login Permissions (Scopes)
      • Authentication
      • Libraries We Use
      • Platform Policy
      • Kebijakan Data Instagram
      • Ketentuan Penggunaan
      • Introducing Checkout on Instagram
      • About Us Head of Instagram
      • Tentang Instagram
Diberdayakan oleh Blogger.
  • About
  • Contact
  • Privacy Policy
  • Disclaimer
Copyright 2018 HGO