Dear all Sorry for missing report relate with Target environment for this report, just add item *7★Target Environment, **8★Notes* --------------------------------------------------------------------- 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: *1★Issue: * Regarding limited from Widget, when try to register BroadcastReceiver via explicit source code: (No effect when register BroadcastReceiver via Manifest.xml) *2★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) *3★Previous solution:* Code Snippet: context.registerReceiver(this, intentName); (1) *4★ Exception when used 3★ solution* 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 *5★Our Solution:* But, We can fixed this by used application context instead of Widget context(*) Code Snippet: context.getApplicationContext.registerReceiver(this, intentName); *6★References:* http://developer.android.com/reference/android/content/Intent.html#ACTION_TIME_TICK Regarding *7★Target Environment:* SDK 2.3, both on Emulator and NexusOne 2.3, If anyone success with this solution please update our report *8★Notes* May be difference between Context object of widget and application, but i still don't known exactly cause of this problem. Please let me known if your have better solution or explain more clearly Regards, DatNQ On Thu, Feb 24, 2011 at 3:06 PM, Nguyen Dat <[email protected]> wrote: > 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 <[email protected]> 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 <[email protected]> > 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. <[email protected]> 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 > [email protected] > > >> To unsubscribe from this group, send email to > > >> [email protected]< > android-developers%[email protected]> > > >> For more options, visit this group at > > >>http://groups.google.com/group/android-developers?hl=en > > > > > -- > > > Dianne Hackborn > > > Android framework engineer > > > [email protected] > > > > > 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 > > [email protected] > > > > 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 [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

