Я разработал приложение, которое позволяет обмениваться изображениями в Instagram. Приложение не имеет ошибок при выполнении, но я не могу поделиться/загрузить изображения в Instagram. Я не мог понять, где это пошло не так. Может кто-то помочь мне с этим. Мои кодировки следующие:
Основная активность.java:
package com.example.dothis.instagram;
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 java.io.File;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// listeners of our two buttons
View.OnClickListener handler = new View.OnClickListener() {
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnConnect:
createInstagramIntent();
break;
}
}
};
// our buttons
findViewById(R.id.btnConnect).setOnClickListener(handler);
}
private void createInstagramIntent() {
Intent share = new Intent(Intent.ACTION_SEND);
// If you want to share a png image only, you can do:
// setType("image/png"); OR for jpeg: setType("image/jpeg");
share.setType("image/*");
// Make sure you put example png image named myImage.png in your
// directory
String imagePath = Environment.getExternalStorageDirectory()
+ "/myImage.png";
File imageFileToShare = new File(imagePath);
Uri uri = Uri.fromFile(imageFileToShare);
share.putExtra(Intent.EXTRA_STREAM, uri);
// Broadcast the Intent.
startActivity(Intent.createChooser(share, "Share to"));
}
}
ApplicationData.java:
package com.example.dothis.instagram;
import android.app.Activity;
public class ApplicationData extends Activity {
public static final String CLIENT_ID = "###########";
public static final String CLIENT_SECRET = "########";
public static final String CALLBACK_URL = "instagram:http://######/";
}
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dothis.instagram" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"></uses- permission>
</manifest>
строки.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Instagram OAuth</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
</resources>
построить.градле:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.dothis.instagram"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
Любые предложения/рекомендации будут действительно полезны. Спасибо