2012-02-21 107 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项目移到了第二个意图过滤节中。