android - Issues in twitter integration using twitter4j

佐手、 提交于 2019-12-08 04:37:39

问题


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>

回答1:


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.




回答2:


New Twiiter integration v 1.1

Check code here

https://github.com/dwivedi/twitter_api_1.1_implementation.git



来源:https://stackoverflow.com/questions/16662996/android-issues-in-twitter-integration-using-twitter4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!