ContentProvider InstantiationException

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

ContentProvider InstantiationException

Postby droozen » Thu Mar 05, 2009 11:54 pm

So, I want to set a repeating alarm that will notify the user every day about something. So I make a repeating alarm that calls my BroadcastReceiver. The only thing my BroadcastReceiver does is start my service, because potentially (not likely, but potentially) it could take some time to do some work.

In my service I have:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.        NotificationManager notifManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  3.  
  4.         Notification notif = new Notification(R.drawable.mydrawable, "Notification Text", System.currentTimeMillis());
  5.  
  6.        
  7.  
  8.         PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
  9.  
  10.                 new Intent(this, My.class), 0);
  11.  
  12.  
  13.  
  14.         ContentResolver resolver = getContentResolver();
  15.  
  16.        
  17.  
  18.         Cursor reminders = resolver.query(MyProvider.CONTENT_URI,
  19.  
  20.                                                   null, null, null, null);
  21.  
  22.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


MyProvider is set up in the manifest as a Content provider, with the same authority as is represented by MyProvider.CONTENT_URI (the uri is context://<the authority>/<more path>)

However, my query method in my ContentProvider never gets called and I can't understand why...
Last edited by droozen on Fri Mar 06, 2009 5:59 pm, edited 1 time in total.
droozen
Developer
Developer
 
Posts: 45
Joined: Wed Feb 25, 2009 10:10 pm

Top

Postby droozen » Fri Mar 06, 2009 2:44 pm

Upon further review, I realize that it was only "working" because the provider tag wasn't under the application tag. By "working", I mean, the reason why my application was running at all. When I put my provider tag under my application tag, like so:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <application -- application data -->
  3.  
  4.         <provider android:name="--Fully qualified path to the class--" android:authorities="--authority--"></provider>
  5.  
  6.         ...
  7.  
  8. </application>
  9.  
  10.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


Now my application won't even start up because the provider won't instantiate.
droozen
Developer
Developer
 
Posts: 45
Joined: Wed Feb 25, 2009 10:10 pm

Postby MrSnowflake » Fri Mar 06, 2009 3:54 pm

Did you look up the error?
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby droozen » Fri Mar 06, 2009 5:04 pm

Sorry, yes. It's an InstantiationException with the class name as the message (or the authority as the message, I put it the same as the class name). No stack trace to provide. I've been trying to query ContentProvider with InstantiationException and getting no helpful results.
droozen
Developer
Developer
 
Posts: 45
Joined: Wed Feb 25, 2009 10:10 pm

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests