Oh, now I see what you meant by "passing the parent activity".. no idea, why I didn't understand it first, guess I shouldn't program more than 6h without a break :D
However, if anyone comes across the same problem as I did, just pass the activity to the class constructor like this: public class CPAddressbook implements IBasicContextProvider { Activity callingActivity; public CPAddressbook(Activity caller) { callingActivity = caller; } //so you can query like that: Cursor c = callingActivity.managedQuery(contactsURI, projection, where, whereArgs, orderBy); } Thanks a lot for your help Dmitri!! :) On Jan 3, 11:46 am, Flo <flo.schw...@gmail.com> wrote: > Okay, so my suspicion was right! > > How can I achieve passing the parent activity to it? > Does this involve Intents? Or should the CPAddressbook simply extend > the parent activity? > > Thanks for your help so far, > Flo. > > On 3 Jan., 02:17, Dmitri Plotnikov <dplotni...@google.com> wrote: > > > Actually, no need for a stack trace. You are manually allocating an > > activity. This should never be done. It would be best to all the work > > in the activity allocated by the system. Of course you can delegate > > the work to a helper object like CPAddressbook, but you will need to > > pass the parent activity to it. > > > Cheers, > > Dmitri > > > On Saturday, January 2, 2010, Dmitri Plotnikov <dplotni...@google.com> > > wrote: > > > Could you post the exception stack trace? > > > > Thank you, > > > Dmitri > > > > On Saturday, January 2, 2010, Flo <flo.schw...@gmail.com> wrote: > > >> Hey there! > > > >> I'm currently working on a component that's retrieving contact > > >> information and creating an RDF model (FOAF tbe) from the data > > >> provided. I started off with the HelloAndroid example and tried some > > >> code in there. Everything worked out fine, so I wanted to put > > >> everything in a seperate class which can be accessed via an interface. > > > >> However, now I'm getting a NullPointer Exception when I want to call a > > >> managedQuery(). > > >> So I tried to create a ContentResolver in order to perform a query(). > > >> But as soon as I call the getContentResolver() I'm getting a > > >> NullPointer Exception as well. > > > >> I think this could be a problem concerning the AndroidManifest.xml or > > >> lack of knowledge about how to handle Activities and the likes? I've > > >> been struggling with that for quite some hours now and think that I > > >> won't solve this on my own, so I'd like to get your opinions and > > >> ideas! > > > >> However, here's my code: > > >> -------------------------------------------------------------------------- > > >> package com.example.helloandroid; > > > >> import it.polimi.elet.contextaddict.microjena.rdf.model.Model; > > >> import it.polimi.elet.contextaddict.microjena.rdf.model.ModelFactory; > > >> import it.polimi.elet.contextaddict.microjena.rdf.model.Resource; > > >> import it.polimi.elet.contextaddict.microjena.vocabulary.RDF; > > >> import android.app.Activity; > > >> import android.database.Cursor; > > >> import android.net.Uri; > > >> import android.os.Bundle; > > >> import android.provider.ContactsContract; > > > >> public class CPAddressbook extends Activity implements > > >> IBasicContextProvider { > > > >> Model contextModel; > > > >> public void onCreate(Bundle savedInstanceState) { > > >> super.onCreate(savedInstanceState); > > >> contextModel = ModelFactory.createDefaultModel(); > > >> } > > > >> @Override > > >> public void detectContext(Model model) { > > > >> Uri contactsURI = ContactsContract.Data.CONTENT_URI; > > > >> String[] projection = new String[] { > > >> ContactsContract.Data._ID, > > >> ContactsContract.Data.CONTACT_ID, > > >> ContactsContract.Data.MIMETYPE, > > >> ContactsContract.Data.DATA1, > > >> ContactsContract.Data.DATA2, > > >> ContactsContract.Data.DATA3, > > >> ContactsContract.Data.DATA4, > > >> ContactsContract.Data.DATA5, > > >> ContactsContract.Data.DATA_VERSION > > >> }; > > >> String where = ContactsContract.Data.MIMETYPE + " = ? > > >> OR " + > > >> ContactsContract.Data.MIMETYPE + " = ? > > >> OR " + > > >> ContactsContract.Data.MIMETYPE + " = ? > > >> OR " + > > >> ContactsContract.Data.MIMETYPE + " = ?"; > > > >> String[] whereArgs = new String[] { > > > >> ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE, > > > >> ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE, > > > >> ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE, > > > >> ContactsContr -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en