Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
LTourist
Old
#1  
Member - OP
Thanks Meter 0
Posts: 70
Join Date: Nov 2009
Default Using GmailProvider.apk

Hi,

I try to make a widget for gmail in order to have the number of unread messages in my gmail box (the only existing app I found is not free and for a such basic feature, that's a shame!). To manage it, I thought about using the GmailProvider package, especially the android.provider.Gmail.LabelCursor class, you can find its documentation here.

I use dynamic loading because I don't have the source code so I can't do a regular import statement (see here).

But I can't manage loading the class in my application, always get an ClassNotFoundException...

Code:
final String apkFile = "/system/app/Gmail.apk:/system/app/GmailProvider.apk";
[...]
dalvik.system.PathClassLoader clsLoader = 
   new dalvik.system.PathClassLoader(apkFile,ClassLoader.getSystemClassLoader());
Class<?> gmailProviderHandler =
   Class.forName("android.provider.Gmail.LabelCursor", true, clsLoader);

Method m = gmailProviderHandler.getDeclaredMethod("getNumConversations", (Class[])null);
int nbConv = ((Integer)m.invoke(gmailProviderHandler, (Object[])null)).intValue();
Any idea ?

An other solution would be to use the atom feed, but using this package seems nicer to me.
Alternatively, is there a way I can get the source of this package, maybe the class name has changed since the javadoc (not official) has been written ???

Thanks,
LTourist
 
LTourist
Old
#2  
Member - OP
Thanks Meter 0
Posts: 70
Join Date: Nov 2009
It's me again...

Nobody can help me ?

On my side, I've made some progress : I finally get some classes from the package. I did a dexdump on the package in xml, and it seems that the classes names do not match the ones in the package... That's kind of strange...

But now, I'm facing another problem... Whatever I do, I'm facing a NullException when I'm calling gmailProviderHandler.NewInstance((Class[]) null), and just for information, gmailProviderHandler seems to be not null, as an equals(null) is false...

Any idea from where this could be coming from ???
 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

report this ad
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...