2012-01-26 7 views
0

アンドロイドを使ってTwitterアプリを書こうとしています。 Twitterのログインページが開き、ログイン後、コールバックURLを開こうとしていて、URLを開けません。 onNewIntentメソッドが呼び出されるように、アプリケーションでコントロールを戻す方法を教えてください。アンドロイド・ツイッター・アプリでコントロールが自分のアプリケーションに戻らない

私は、マニフェストファイルにインテントフィルタを提供し、onResumeを実装してもまだ役に立たないというような多くの記事で述べたソリューションを試しました。

<application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".MyTwitter" 
        android:label="@string/app_name"> 

      <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="OAuthTwitter" android:host="myTweet" /> 
      </intent-filter> 
      ... 

Javaコード事前に

final public static String CALLBACK_URL = "myTweet-OAuthTwitter:///"; 
commonHttpOAuthConsumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); 
authProvider = new DefaultOAuthProvider("http://twitter.com/oauth/request_token", "http://twitter.com/oauth/access_token", "http://twitter.com/oauth/authorize"); 
try {  
    String oAuthURL = authProvider.retrieveRequestToken(commonHttpOAuthConsumer, CALLBACK_URL);  
    this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(oAuthURL))); 
} 
catch (OAuthMessageSignerException e) {  
    Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();  
    e.printStackTrace();  
} 
catch (OAuthNotAuthorizedException e) {  
    Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();  
    e.printStackTrace();  
} 
catch (OAuthExpectationFailedException e) {  
    Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();  
    e.printStackTrace();  
} 
catch (OAuthCommunicationException e) {  
    Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();  
    e.printStackTrace();  
} 

protected void onNewIntent(Intent intent) { 
} 

ありがとう:ここ

は、マニフェストファイルです。

答えて

0

私はこのようなURLコールバックを考える: OAuthTwitter:// myTweet

+0

おかげで、これは:-)働いていた多くのことを。 onCreateはonNewIntentの代わりに呼び出され、これを修正しようとしています。 –

関連する問題