2012-12-31 29 views
1

我一直在尝试将我的应用程序连接到Android,但我没有运气。我一直在寻找几个小时,但我发现的所有资源都不完整或过时。我得到这个至今:Twitter OAuth回调似乎不适用于Android

private class MyAsync extends AsyncTask<Void, Void, AccessToken> { 

    @Override 
    protected AccessToken doInBackground(Void... params) { 
     try { 
      requestToken = twitter.getOAuthRequestToken(); 
      Intent browserIntent = new Intent(Intent.ACTION_VIEW, 
        Uri.parse(requestToken.getAuthorizationURL())); 
      startActivity(browserIntent); 
     } catch (TwitterException e) { 

      e.printStackTrace(); 
     } 
     Log.d("token", "here1"); 
     return token; 
    } 

} 

上述工作尽可能打开授权page.However当我添加一个回调URL(如下)应用程序停止工作。它甚至不会再打开浏览器:

twitter.getOAuthRequestToken("myapp://callback"); 

我读的地方,我应该下面意向过滤器添加到清单文件。但是这并没有影响结果:

 <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="myapp" android:host="callback" /> 
     </intent-filter> 

如果它可以帮助我使用twitter4j库。

+0

做更多的..检出这个项目http://code.google.com/p/droidtwit/和https://github.com/browep/Android-OAuth-Twitter-Example和https:// github。 com/grantland/twitter-android-sdk以及本教程系列http://marakana.com/forums/android/examples/67.html – MKJParekh

回答

1

好吧,我明白了。我只需要在应用程序的twitter页面中插入一个虚拟回调网址。这种直觉和丑陋的解决方案。