Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 08 Apr 2013
Offline Last Active Apr 19 2013 08:59 AM

Topics I've Started

errors trying to use loaders in android

08 April 2013 - 11:13 AM

So I'm trying to make AOuth work in android for twitter. Here's the code I'm having errors with in my activity:

public Loader<OAuthConsumer> onCreateLoader(int id, Bundle arg1) {

    consumerLoader = new getCommonsHttpOAuthConsumer(); //consumerLoader is declared in the activity as "private Loader<OAuthConsumer> consumerLoader;"
    return consumerLoader;
        // After this method you're going in loadInBackground()

Here's the code for my asyncTaskLoader:

class getCommonsHttpOAuthConsumer extends AsyncTaskLoader<OAuthConsumer>{

	public getCommonsHttpOAuthConsumer(Context context) {
		// TODO Auto-generated constructor stub

	public OAuthConsumer loadInBackground() {
		// TODO Auto-generated method stub
		return new CommonsHttpOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);

This is a 2 part question. 1st question: I get an error when I use import android.support.v4.app.LoaderManager The error is on Loader<OAuthConsumer>. It says "The return type is incompatible with LoaderManager.LoaderCallbacks.onCreateLoader(int, Bundle)". But the error goes away if I use import android.app.LoaderManager instead. My question is: Should I try to fix the error with using the support library, so that more devices will be compatible with my app? If yes, how can I fix that error?


2nd question: No matter what import I use, I get an error on new getCommonsHttpOAuthConsumer(); The error says: "Type mismatch: cannot convert from getCommonsHttpOAuthConsumer to Loader". What am I doing wrong?