There isn't a way that I am aware of. On Mon, Jun 22, 2009 at 5:20 PM, k kruups <kkru...@gmail.com> wrote:
> Hi Dianne, > > Thank you for quick response. Given that this is not supported, > > What would be the appropriate method to capture email/sms for non-gmail > and gmail data transactions? > > Example mail fields to/from, subject, date, attachments included or not, > etc... > Regards, > > kk > >> >> >> ------------------------------ >> *From:* android-framework@googlegroups.com [mailto: >> android-framew...@googlegroups.com] *On Behalf Of *Dianne Hackborn >> *Sent:* Tuesday, June 23, 2009 7:32 AM >> *To:* android-framework@googlegroups.com >> *Subject:* Re: BroadcastReceiver and Google Services Inquiry >> >> PROVIDER_CHANGED is usually -only- used for updating the new mail status >> bar icon. It is not intended for generally monitoring a provider. >> >> Also the Gmail provider schema is not public (not even part of the >> platform at all), so you can't write code against it and expect it to >> continue to work in the future. >> >> On Mon, Jun 22, 2009 at 12:11 AM, kkruups <kkru...@gmail.com> wrote: >> >>> >>> Hi All, >>> >>> I have been working on BroadcastReceiver code to capture GMAIL events >>> and try to extract data to create an email event log. >>> >>> Although the registration of the BroadcastReceiver using >>> Intent.PROVIDER_CHANGED for gmail appears to be correctly formed and >>> no exceptions are generated. I have my doubts whether the receiver is >>> able to capture gmail event for Intent.PROVIDER_CHANGED, generated >>> when unread email is available, since code in my BroadcastReceiver is >>> never activated. Upon reading the BroadcastReciever API docs (see >>> excerpt below) I see that BroadcastReceivers are not designed to >>> capture intents used with startActivity() and that BroadcastReceivers >>> only receive intents generated from a sendBroadcast() method call. >>> For your reference see my code snippets below. >>> >>> Is the BroadcastReceiver mechanism not the appropriate method to >>> capture email/gmail/sms events? >>> >>> >>> >>> BroadcastReceiver code is the following: >>> >>> public class EmailReceiver extends BroadcastReceiver { >>> /** >>> * >>> */ >>> >>> String TAG= "MY_TAG:RECEIVER"; >>> >>> @Override >>> public void onReceive(Context context, Intent intent) { >>> // >>> Log.i(TAG, "Action=" + intent.getAction()); >>> if (Intent.ACTION_PROVIDER_CHANGED.equals >>> (intent.getAction >>> ())) { >>> Uri dataURI= intent.getData(); >>> String dataURIPath=dataURI.getPath(); >>> Log.i(TAG, dataURIPath); >>> } >>> } >>> } >>> >>> >>> BroadcastReceiver code registration for gmail is the following: >>> // >>> >>> @override >>> public void onCreate(Bundle b){ >>> .... >>> >>> EmailReceiver myMailReceiver = new EmailReceiver(); >>> >>> ...... >>> >>> } >>> >>> >>> @Override >>> public void onResume(){ >>> super.onResume(); >>> >>> try{ >>> IntentFilter mailFilter = new IntentFilter >>> ( Intent.ACTION_PROVIDER_CHANGED, "content://gmail-ls/unread/^i"); >>> // IntentFilter mailFilter = new IntentFilter >>> ( Intent.ACTION_PROVIDER_CHANGED, "gmail-ls"); >>> registerReceiver( myMailReceiver, mailFilter); >>> Log.i(myMailReceiver.TAG, "MailReceiver registered"); >>> }catch(Exception e){ >>> Log.e(myMailReceiver.TAG, "Intent Filter malformed"); >>> } >>> >>> } >>> >>> Excerpt from BroadcastReceiver Doc: >>> >>> Base class for code that will receive intents sent by sendBroadcast >>> (). >>> ........ >>> ........ >>> >>> Note that, although the Intent class is used for sending and receiving >>> these broadcasts, the Intent broadcast mechanism here is completely >>> separate from Intents that are used to start Activities with >>> Context.startActivity(). There is no way for a BroadcastReceiver to >>> see or capture Intents used with startActivity(); likewise, when you >>> broadcast an Intent, you will never find or start an Activity. These >>> two operations are semantically very different: starting an Activity >>> with an Intent is a foreground operation that modifies what the user >>> is currently interacting with; broadcasting an Intent is a background >>> operation that the user is not normally aware of. >>> >>> ......... >>> >>> Regards, >>> >>> KK >>> >>> >> >> >> -- >> Dianne Hackborn >> Android framework engineer >> hack...@android.com >> >> Note: please don't send private questions to me, as I don't have time to >> provide private support, and so won't reply to such e-mails. All such >> questions should be posted on public forums, where I and others can see and >> answer them. >> >> >> > > > > -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "android-framework" group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~----------~----~----~----~------~----~------~--~---