check below code: you have to use use twitter4j-core-2.1.11.jar
& twitpic4j.jar
before use this checkthispost.
Login in to twitter using above android code.
You must have to login in twitter and use OAUTH_TOKEN
& OAUTH_TOKEN_SECRET
in this method. in this i have passed URL
same way you can also pass bitmap
.
private void hello() {
// TODO Auto-generated method stub
String url;
long result = 0;
String oth = prefs.getString(OAuth.OAUTH_TOKEN, "");
String src = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");
Configuration conf = new ConfigurationBuilder()
.setOAuthConsumerKey(Constants.CONSUMER_KEY)
.setOAuthConsumerSecret(Constants.CONSUMER_SECRET)
.setOAuthAccessToken(oth).setOAuthAccessTokenSecret(src)
.build();
OAuthAuthorization auth = new OAuthAuthorization(conf,
conf.getOAuthConsumerKey(), conf.getOAuthConsumerSecret(),
new AccessToken(conf.getOAuthAccessToken(),
conf.getOAuthAccessTokenSecret()));
ImageUpload upload = ImageUpload.getTwitpicUploader(
Constants.twitpic_api_key, auth);
Log.d(main_genral_class.TAG, "Start sending image...");
try {
url = upload.upload(" ", new URL("https://i.stack.imgur.com/wz0qZ.jpg").openStream(),
"some text");
} catch (Exception e) {
e.printStackTrace();
}
}
url
is give you URL of uploaded image
for bitmap you can use like : upload.upload(String, inputstream);
Edited
I have checked my code and replace twitter4j-core-2.1.11.jar
to twitter4j-core-3.0.3.jar
check full code here
and also change some setting in Twitter App on https://dev.twitter.com


its working fine....