Share text/Image on twitter and facebook in androi

2019-04-13 15:52发布

I have developed my news app and now i have to add share(facebook/twitter)option to share image and text.I have searched lot but not clear how to fulfill my requirement.Actually on share button i have to display edittext and button and whatever we have to share on clicking on share button that should be shared.I have gone through SDK and intent also but not working for my requirement`

String twitterUri = "http://m.twitter.com/?status=";
        String marketUri = "TESTING ";
        Intent shareOnTwitterIntent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(twitterUri + marketUri));
        startActivity(shareOnTwitterIntent);.

2条回答
淡お忘
2楼-- · 2019-04-13 16:07

You can share image and test on twitter by using twitter4j-core-3.0.2.jar twitter4j-media-support-3.0.2.jar library. example

String token = prefs.getString(OAuth.OAUTH_TOKEN, "");
 String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");

 AccessToken a = new AccessToken(token, secret);
 Twitter twitter = new TwitterFactory().getInstance();
 twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
 twitter.setOAuthAccessToken(a);

 ConfigurationBuilder cb = new ConfigurationBuilder();
 cb.setDebugEnabled(true).setOAuthConsumerKey(yourConsumerKey).setOAuthConsumerSecret(yourConsumerSeceret).setOAuthAccessToken(yourAccessToken).setOAuthAccessTokenSecret(yourAccessTokenSeceret);

 Configuration conf = cb.build();

 ImageUploadFactory factory = new ImageUploadFactory(conf);
 ImageUpload upload = factory.getInstance();
 String url = upload.upload(yourImage, yourCaptionWithImage); //image is a File Format and Caption is String 

Reference link :

1) http://www.londatiga.net/it/how-to-send-image-to-twitpic-from-android/

2) http://www.rqna.net/qna/wupzh-android-image-sharing-on-twitter-using-sdk.html

查看更多
Luminary・发光体
3楼-- · 2019-04-13 16:09

Hey you can get help from the below link for facebook image uploading

Android facebook SDK, upload pictures to wall with profile in different language?

and for Twitter you need to upload it in twitpic... for that you have to use jar file.. as you can't tweet picture in twitter.

查看更多
登录 后发表回答