如何上传图像中的android叽叽喳喳 [英] How to post image to twitter in android

查看:132
本文介绍了如何上传图像中的android叽叽喳喳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要发布一个在我的应用程序到Twitter创建的映像。我不知道如何做到这一点,我在想,如果有一个SDK的偷笑像有对Facebook的? 在此先感谢

I want to post an image that is created in my app to twitter. I don't know how to do this and I was wondering if there is an SDK for titter like there is for Facebook? Thanks in advance

推荐答案

首先,您需要创建在Twitter上的应用程序

First you need to create an app on twitter

下面是code张贴在Twitter上的消息

here is code to post message on twitter

 ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
        configurationBuilder.setOAuthConsumerKey(context.getResources().getString(R.string.twitter_consumer_key));
        configurationBuilder.setOAuthConsumerSecret(context.getResources().getString(R.string.twitter_consumer_secret));
        configurationBuilder.setOAuthAccessToken(LoginActivity.getAccessToken((context)));
        configurationBuilder.setOAuthAccessTokenSecret(LoginActivity.getAccessTokenSecret(context));
        Configuration configuration = configurationBuilder.build();
        final Twitter twitter = new TwitterFactory(configuration).getInstance();

        new Thread(new Runnable() {

                private double x;

                @Override
                public void run() {
                        boolean success = true;
                        try {
                                x = Math.random();
                                twitter.updateStatus(message +" "+x);
                        } catch (TwitterException e) {
                                e.printStackTrace();
                                success = false;
                        }

                        final boolean finalSuccess = success;

                        callingActivity.runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                        postResponse.onFinsihed(finalSuccess);
                                }
                        });

                }
        }).start(); 

检查该<一href="http://learnn$c$c.word$p$pss.com/2013/12/17/tutorial-on-uploading-image-on-twitter-using-twitter4j/"相对=nofollow>教程了解更多详情。

这篇关于如何上传图像中的android叽叽喳喳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆