2012-02-21 119 views
0

(後更新的工作代碼)Android,Twitter和OAuth:協議不支持?

我一直試圖讓我的Android應用程序與Twitter授權,然後趕上身份驗證令牌在我的應用程序的回調URL。

我想我的AndroidManifest.xml中有問題。據我所知,如果我使用android:launchmode =「singleTask」啓動我的應用程序,那麼我需要在我的主要活動的onResume()方法中檢索AccessToken對象。

如果我沒有指定singleTask啓動,那麼我需要在onNewIntent()方法中進行檢索。

我已經在我的清單文件中嘗試了兩種方式,但我沒有在onNewIntent()或onResume()中獲得控制權。 Twitter會使用我的回調網址重定向,但網頁瀏覽器會提示「網頁不可用」。和logcat說:

Tab E onReceivedError -10 myapp://www.authtoke.app?oauth_token=2Y3jZMfHZ06Teezzy3l1KvlWqs961tsqXFlTgMHrA&oauth_verifier=PBfCueZLEzEteBoLTksDARQDRi3raVi5FiEJllCYus The protocol is not supported. 

任何人都知道我已經弄糟了嗎?這裏的清單條目:

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

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

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 

    <application android:name=".myAppVars" android:icon="@drawable/ic_launcher" android:label="@string/app_name" > 
     <activity android:name=".TwitterLibActivity" android:label="@string/app_name" android:launchMode="singleTask"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" > </action> 
       <category android:name="android.intent.category.LAUNCHER" ></category> 
      </intent-filter> 

      <intent-filter> 
       <action android:name="android.intent.action.VIEW" > </action> 
       <category android:name="android.intent.category.DEFAULT" ></category> 
       <category android:name="android.intent.category.BROWSABLE" > </category> 
       <data android:scheme="myapp" android:host="www.authtoke.app"> </data> 
      </intent-filter> 
     </activity> 

    </application> 

</manifest> 
+0

在這裏找到答案:http://androidforums.com/introductions/218621-twitter4j-oauth-android-simple.html。編輯清單,所以它的作品。我將VIEW,DEFAULT和BROWSABLE項目移到了第二個意圖過濾節中。 – wufoo 2012-02-21 18:32:55

+0

Yous應在下面添加您的答案並標記解決。 – brk3 2012-03-03 11:57:11

回答

1

在這裏找到了答案:androidforums.com/introductions/...。編輯清單,所以它的作品。我將VIEW,DEFAULT和BROWSABLE項目移到了第二個意圖過濾節中。