Android的 - 使用twitter4j问题在Twitter的整合 [英] android - Issues in twitter integration using twitter4j

查看:371
本文介绍了Android的 - 使用twitter4j问题在Twitter的整合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,Twitter的整合在android系统。我用这个教程集成的Twitter在Android应用程序。在这里,我遇到了一些问题。


  1. 我的应用程序只能从ICS如果我移除了manifeast的targetversion执行。为什么呢?

<使用-SDK
        安卓的minSdkVersion =8
       机器人:targetSdkVersion =15/>

下面我删除了android:targetSdkVersion =15从manifeast文件。

现在,
<使用-SDK
        安卓的minSdkVersion =8/>

2.In叽叽喳喳的开发者控制台,我把我的应用程序的回调URL是的https:/ /www.google.co.in/ ,然后我试图使用运行在我们的code这个回调URL这个程序。其实成功登入后,它应该重定向到应用程序,但在这里它会重定向到回调URL(这里指谷歌控制台)。

静态最后弦乐TWITTER_CALLBACK_URL = https://www.google.co.in/

但在这里我设置以下回调URL我们code,那么它的正常工作。为什么?它是在twitter4j默认的回调URL。请谁能帮助我。

静态最后弦乐TWITTER_CALLBACK_URL =的OAuth:// t4jsample

Manifeast文件

 <清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=com.androidhive.twitterconnect
    安卓版code =1
    机器人:=的versionName1.0>    <用途-SDK
        安卓的minSdkVersion =8
        />    <应用
        机器人:图标=@绘制/ ic_launcher
        机器人:标签=@字符串/ APP_NAME
        机器人:主题=@风格/ AppTheme>
        <活动
            机器人:名字=。MainActivity
            机器人:标签=@字符串/ title_activity_main>
            &所述;意图滤光器>
                <作用机器人:名字=android.intent.action.MAIN/>                <类机器人:名字=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
            &所述;意图滤光器>
                <作用机器人:名字=android.intent.action.VIEW/>
                <类机器人:名字=android.intent.category.DEFAULT/>
                <类机器人:名字=android.intent.category.BROWSABLE/>
                <数据机器人:计划=OAuth的机器人:主机=t4jsample/>
            &所述; /意图滤光器>
        < /活性GT;
    < /用途>    <! - 审批 - Internet连接 - >
    <使用许可权的android:NAME =android.permission.INTERNET对/>    <! - 网络状态权限 - >
    <使用许可权的android:NAME =android.permission.ACCESS_NETWORK_STATE/>< /&舱单GT;


解决方案

重定向到URL回调身份验证后是正常的行为。请阅读一些关于的OAuth 第一。回叫URL被用于传递授权令牌返回给请求应用程序。你应该分配给你的应用程序中的URL可以读出令牌并使用必要的行动。在twitter4j的情况下,URL 的OAuth:// t4jsample 能够处理这一部分。希望这是明确的给你。

I am newbie to twitter integration in android. I integrated twitter in android app using this tutorial. Here i faced some problems.

  1. My App is only executed from ICS if i removed the targetversion from the manifeast. Why?

< uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />

Here i removed the android:targetSdkVersion="15" from manifeast file.

Now, < uses-sdk android:minSdkVersion="8" />

2.In the developer console of the twitter, i set the callback url of my app is "https://www.google.co.in/" and then i am trying to run this app using this callback url in our code. Actually after successful signin, it should redirects to the app but here it will redirects to the callback url(means here google console).

static final String TWITTER_CALLBACK_URL = "https://www.google.co.in/";

But here i set the following callback url in our code then it's working fine. Why? is it the default callback url in twitter4j. Please can anyone help me.

static final String TWITTER_CALLBACK_URL = "oauth://t4jsample";

Manifeast file

< manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.androidhive.twitterconnect"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8" 
        />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="oauth" android:host="t4jsample"/>
            </intent-filter>
        </activity>
    </application>

    <!-- Permission - Internet Connect -->
    <uses-permission android:name="android.permission.INTERNET" />

    <!-- Network State Permissions -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

< /manifest>

解决方案

Redirecting to callback URL after authentication is the normal behavior. Please read a bit about OAuth first. Call back URL is used to pass authorization token back to the requesting application. You should assign this to a url inside your application which can read the token and take necessary actions using that. In case of twitter4j, the URL oauth://t4jsample is able to handle this part. Hope this is clear to you.

这篇关于Android的 - 使用twitter4j问题在Twitter的整合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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