OnResume method does not work for Twitter Implementation

Trying to integrate Twitter with my application. Follow the tutorials, but it does not work.

I have a PreferenceActivity that has a CheckBoxPreference . If I click, I do the following:

 chkTwitter.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference _pref) { Intent fbIntent = new Intent(getApplicationContext(), TwitterConnectActivity.class); _pref.setIntent(fbIntent); return false; } }); 

My TwitterConnectActivity is called, I am setting up an Oauth object and is being called to the Twitter authentication website.

When I click Authorize Application, my onResume :

 @Override protected void onResume() { super.onResume(); if (this.getIntent()!=null && this.getIntent().getData()!=null){ Uri uri = this.getIntent().getData(); if (uri != null && uri.toString().startsWith(CALLBACK_URL)) { String verifier = uri.getQueryParameter(oauth.signpost.OAuth.OAUTH_VERIFIER); 

The problem is that this.getIntent().getData() is null, so I never go into the if condition.

My AndroidManifest is as follows:

  <activity android:name=".SettingsActivity" android:label="@string/app_name" android:screenOrientation="portrait" > <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:host="my_twitter" android:scheme="callback" /> </intent-filter> </activity> <activity android:name=".TwitterConnectActivity" android:label="@string/app_name" android:screenOrientation="portrait" > </activity> 

Most likely, I defined my callback URL, for example: private String CALLBACK_URL = "callback://my_twitter";

Can anybody help me?

Cheers, Felipe

+4
source share
1 answer

use StartActivityForResult instead.

0
source

All Articles