The Instagram API Platform can be used to build non-automated, authentic, high-quality apps and services that:
Help individuals share their own content with 3rd party apps.
Help brands and advertisers understand, manage their audience and media rights.
Help broadcasters and publishers discover content, get digital rights to media, and share media with proper attribution.
Instagram did not open their sharing API. You have to use Intents ...Here is the example for sharing images with Instagram using intents.
Resource Link_1 Resource Link_2 Resource Link_3
Here is the link to download the source code
Note: Before executing the above code you should keep one image with the name as Capture.png (InternalStorage/Capture.png)or you can use your image path..
Help individuals share their own content with 3rd party apps.
Help brands and advertisers understand, manage their audience and media rights.
Help broadcasters and publishers discover content, get digital rights to media, and share media with proper attribution.
Instagram did not open their sharing API. You have to use Intents ...Here is the example for sharing images with Instagram using intents.
Resource Link_1 Resource Link_2 Resource Link_3
package com.example.instagramshare;
import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
Button mButtonWhatsappShare;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mButtonWhatsappShare = (Button) findViewById(R.id.button_share);
mButtonWhatsappShare.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String type = "image/*";
String filename = "/Capture.png";
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);
share.setPackage("com.instagram.android");
// 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);
share.putExtra(Intent.EXTRA_TEXT, "This is my text to send Instagram.");//Instagram will not take text as input..
try {
startActivity(share);
} catch (Exception e) {
// TODO: handle exception
Toast.makeText(MainActivity.this, "Instagram application not found..", Toast.LENGTH_SHORT).show();
}
}
}
import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
Button mButtonWhatsappShare;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mButtonWhatsappShare = (Button) findViewById(R.id.button_share);
mButtonWhatsappShare.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String type = "image/*";
String filename = "/Capture.png";
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);
share.setPackage("com.instagram.android");
// 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);
share.putExtra(Intent.EXTRA_TEXT, "This is my text to send Instagram.");//Instagram will not take text as input..
try {
startActivity(share);
} catch (Exception e) {
// TODO: handle exception
Toast.makeText(MainActivity.this, "Instagram application not found..", Toast.LENGTH_SHORT).show();
}
}
}
Here is the link to download the source code
Note: Before executing the above code you should keep one image with the name as Capture.png (InternalStorage/Capture.png)or you can use your image path..
No comments:
Post a Comment