errors trying to use loaders in android

Put your problem here if it does not fit any of the other categories.

errors trying to use loaders in android

Postby jello » Mon Apr 08, 2013 6:29 pm

So I'm trying to make AOuth work in android for twitter. Here's the code I'm having errors with in my activity:
Code: Select all
@Override
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:
Code: Select all
class getCommonsHttpOAuthConsumer extends AsyncTaskLoader<OAuthConsumer>{

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

   @Override
   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?
jello
Freshman
Freshman
 
Posts: 2
Joined: Mon Apr 08, 2013 6:24 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 18 guests