Twitter4j getOAuthRequestToken()与回调URL无法在Android? [英] Twitter4j getOAuthRequestToken() with callback URL fails on Android?

查看:154
本文介绍了Twitter4j getOAuthRequestToken()与回调URL无法在Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想微博融入我的Andr​​oid应用程序,并似乎无法得到Twitter4j登记自己的应用程序。

I am trying to integrate Twitter into my Android Application and can't seem to get Twitter4j to register my app.

就我见过的对于Android的问题,每一个教程和问题已有多年的老东西似乎从那时起已经移动了。

Every tutorial and question regarding the issue I've seen for Android have been years old and things seem to have moved on since then.

我也跟着上本教程的步骤和使用提供的源code到测试连接到Twitter。明知与源$ C ​​$ c供给的Twitter4j版本已经过时,我更新了它的最新版本和快照版本以后,但都无济于事。

I followed the steps on this tutorial and used the supplied source code to test connecting to Twitter. Knowing that the Twitter4j version supplied with the source code was out of date I updated it the latest version and snapshot version later on, but all to no avail.

private void loginNewUser() {
    try {
        Log.i(TAG, "Request App Authentication");

        // This line fails with error "Host is unresolved: api.twitter.com:80
        mReqToken = mTwitter.getOAuthRequestToken(); 

        Log.i(TAG, "Starting Webview to login to twitter");
        WebView twitterSite = new WebView(this);
        twitterSite.loadUrl(mReqToken.getAuthenticationURL());
        setContentView(twitterSite);

    } catch (TwitterException e) {
        Log.e("errors", e.getMessage());
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
    }
}

任何人都有使用Twitter4j任何工作登录code或知道一个解决问题的办法,我会感谢您的来信!

Of anyone has any working login code using Twitter4j or knows a solution to the problem I'd be grateful to hear from you!

推荐答案

好吧,我想通了,我希望像我一样的人谁遇到同样的问题,并没有受到影响。

Okay I figured it out and I hope anyone who comes across the same problem doesn't have to suffer as I did.

1)错误主持人是没有得到解决:api.twitter.com:80源于一个事实,即该装置没有一个WiFi信号或3G连接(WiFi的是一个有点片状在我工作办公室)

1) The error "Host is unresolved: api.twitter.com:80" comes from the fact that the device did not have a WiFi signal or 3G connectivity (The WiFi is a bit flaky in the office I work in).

2) getOAuthRequestToken()崩溃在任何Android版本大于3.0蜂巢由于HTTP请求需要对从UI线程独立的线程中完成的。我有这个问题,因为我已经设定了目标版本在我的Andr​​oid清单到4.0冰淇淋三明治。

2) getOAuthRequestToken() crashes in any Android version greater than 3.0 Honeycomb because HTTP requests need to be done on a separate thread from the UI thread. I had this problem because I had set the target version in my Android manifest to 4.0 Ice Cream Sandwich.

这篇关于Twitter4j getOAuthRequestToken()与回调URL无法在Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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