Dear Henry, This is result after investigate this problem, i was handler successful this issue. So i collect as report to share with android developer. Hope it help
Here is result: ★Issue: Regarding limited from Widget, when try to register BroadcastReceiver via explicit source code: (No effect when register BroadcastReceiver via Manifest.xml) ★Example: BroadcastReceiver: ACTION_TIME_TICK message is one example: As docs from Android had point out: "You can not receive this through components declared in manifests, only by exlicitly registering for it with Context.registerReceiver()." (Ref.1) ★Previous solution: Code Snippet: context.registerReceiver(this, intentName); (1) ★When implement follow (1), it though exception: android.content.ReceiverCallNotAllowedException: IntentReceiver components are not allowed to register to receive intents ★Good news for anyone who need to register BroadcastReceiver in Widget :) we CAN register successful BroadcastReceiver ★Our Solution: But, We can fixed this by used application context instead of Widget context(*) Code Snippet: context.getApplicationContext.registerReceiver(this, intentName); ★References: http://developer.android.com/reference/android/content/Intent.html#ACTION_TIME_TICK Regarding Regards, DatNQ On Dec 3 2009, 12:44 am, Dianne Hackborn <hack...@android.com> wrote: > Oh and please keep in mind -- app widgets were very deliberately designed to > work this way because on the vast majority of Android devices there is just > not nearly enough memory to be able to run at the same time all of the > widget users have placed on their home screen. You need to take care in > your widget implementation that you respect this constraint -- a widget can > NOT be running all of the time, it must be very carefully designed to run as > little as possible and only when needed. > > > > On Wed, Dec 2, 2009 at 9:42 AM, Dianne Hackborn <hack...@android.com> wrote: > > You simply can not do this. A BroadcastReceiver component only "lives" for > > the duration of the call to onReceiveIntent(); it is not allowed to use > > registerReceiver in it, because by the time you return from that method (at > > which point you could first receive anything from your register), the > > component is no longer alive, and the system could kill at any time to > > reclaim memory. > > > On Wed, Dec 2, 2009 at 1:04 AM, Henry S. <stanal...@gmail.com> wrote: > > >> Hi, > > >> I am making a widget that needs a broadcast receiver, like the one in > >> com.example.android.apis.appwidget.ExampleBroadcastReceiver. However, > >> the example defines Intent.ACTION_TIMEZONE_CHANGED in the manifest, > >> but there are some that do not allow this > > >> For example, Intent.ACTION_TIME_TICK says "You can not receive this > >> through components declared in manifests, only by exlicitly > >> registering for it with Context.registerReceiver(). " > > >> So I removed the manifest declarations and tried replacing the > >> AppWidgetProvider.onEnabled function that was in the example with a > >> call like the following: > >> context.registerReceiver(myReceiver, new > >> IntentFilter(Intent.ACTION_TIME_TICK)); > > >> (where "myReceiver" is an instance of the receiver I want.) However, > >> when I try to run the code, I get the following error: > > >> Unable to start > >> receiver...android.content.ReceiverCallNotAllowedException: > >> IntentReceiver components are not allowed to register to receive > >> intents > > >> Can anyone suggest a way to get this broadcast receiver working from a > >> widget? > > >> Thanks, > >> Henry > > >> -- > >> 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<android-developers%2bunsubscr...@googlegroups.com> > >> For more options, visit this group at > >>http://groups.google.com/group/android-developers?hl=en > > > -- > > 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 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