Android : How to handle the popup “Complete action Using” with my 2 activities for twiiter API using scribe?

on Saturday, October 11, 2014


In my android application we are using scribe API, In application have two types logins. i.e one is our private aunthentication, another one is login with Twitter. For the Twitter we are using scribe api. if we go login with twitter, after authentication ahs been completed, getting pop like “Complete action Using” with my 2 activities, LoginActivity, FeedsActivity.


Appliation manifest code is here



<activity
android:name=".LauncherActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<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:host="twitter"
android:scheme="oauth" />
</intent-filter>
</activity>
<activity
android:name=".FeedsActivity"
android:label="@string/title_activity_feeds"
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="twitter"
android:scheme="oauth" />
</intent-filter>
</activity>


And code for calling twitter, we use below async task



public class TwitterAuthenticationTask extends AsyncTask<String, Void, String> {

public static Token mRequestToken;
public static OAuthService service;
private Context context;
private String apiKey, apiSecret, callback;
private Dialog progressDialog;

public TwitterAuthenticationTask(Context context) {
this.context = context;
this.apiKey = context.getResources().getString(R.string.twitterApiKey);
this.apiSecret = context.getResources().getString(R.string.twitterApiSecret);
this.callback = context.getResources().getString(R.string.twitterCallback);
}

@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = CommonUtils.getProgressDialog(context, context.getResources().getString(R.string.app_name));
}
@Override
protected String doInBackground(String... params) {
service = new ServiceBuilder()
.provider(TwitterApi.SSL.class)
.apiKey(apiKey)
.apiSecret(apiSecret)
.callback(callback)
.build();
mRequestToken = service.getRequestToken();
String authUrl = service.getAuthorizationUrl(mRequestToken);
return authUrl;
}

@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
progressDialog.dismiss();
Intent i = new Intent(Intent.ACTION_VIEW);
i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
i.setData(Uri.parse(result));
context.startActivity(i);
}


}


In this application we are having Twitter authentication in two activities, login with twitter any one of activity. Here we are using scribe api for twitter, the problem is after completing twitter authentication showing popup like “Complete action Using”, in that pop showing my two activities i.e LoginActivity & FeedsActivity. Here my requirement is after twitter authentication has completed,just come back to previous activity, in which we are calling Twitter instead of popup. I think problem with same intent-filters for two activities, How to handle this problem? we are Trying to solve this issue from four days. I hope anybody give the solution for this.


Thanks in advance.


0 comments:

Post a Comment