BroadcastReceiver dilemma

by Klaus Kartou » Fri, 23 Apr 2010 15:26:18 GMT

Sponsored Links

I recently added functionality to my app that does a simple state check on a
boolean when the connectivity state changes.
In order to do this i register a broadcast receiver that is invoked as soon
as the phones connectivity state changes.
This is all fine and works just as intended. However, a side effect of this
is that the application context is launched every time there is a change in
the connection. As a developer I know that this is ok, because the system
can just kill the context whenever it wants. But users that use any kind of
app-killer sees that the app is regularly reoccurring on the list of running
app, and therefore thinks that the app does unnecessary background work and
takes up resources.
So how do i 'solve' this 'issue'. I cant expect the users to understand the
underlying functionality of the OS...and people are uninstalling the app
because they dont like that it is reoccuring on the app-killer list...

Any thoughts? :)



BroadcastReceiver dilemma

by Kumar Bibek » Fri, 23 Apr 2010 15:35:42 GMT

 Well, it's a difficult and funny situation. I will provide a funny
solution as well.

When your receiver is waking up, hunt down for the App-Killer app and
kill it. :) There's always a compromise that has to be made in such
cases. You cannot really do anything. Maybe, your receiver needs to
wake up less frequently to get away from the Killer program.

Thanks and Regards,
Kumar Bibek

But, yes, this is kind of irritating.


Sponsored Links

Other Threads

1. Example "Lunar Lander" crashes & gives strange messages

Hi everybody,

I build Lunar Lander (from the android-1.5 directory) and launched it
in the emulator.

When i press the home-button while playing, the homescreen is
displayed if i start lunar lander again (to get back to the game) it
crashes with "E/AndroidRuntime(  711):
java.lang.IllegalThreadStateException: Thread already started.".
(Sidenote: Leaving with the back-button an returning seems to work.)

Is that a flaw in the example, or am I doing something wrong?

Also while it is running when started normally adb logcat shows the
following message periodically:
"W/SurfaceFlinger(  568): executeScheduledBroadcasts() skipped,
contention on the client. We'll try again later..."

Is this another flaw in the example (maybe incorrect handling of the

Thanks for any enlightenment on those questions.

ps: tried googling, but the surfaceFlinger thing only seems to comes
up as a sideeffect in crash logs for the emulator.

-- jp


2. Crash when bringing activity to foreground

The Android Application Framework FAQ states:
"The general mechanism to start a new activity if its not runningor
to bring the activity stack to the front if is already running in the
backgroundis the to use the NEW_TASK_LAUNCH flag in the startActivity
() call."

I have some fairly simple code that allows the user to switch between
running tasks.  Most of the time things work fine, but there a few
scenarios that cause my program to crash.

First, here is the code that I am using to bring a "running" activity
to the foreground:

ActivityManager.RunningTaskInfo task = getTask(idx);
if (task != null)
        Intent intent = new Intent();

        catch (ActivityNotFoundException e)
                Toast.makeText(m_context, "Unable to launch activity...",

- Crash Scenario 1:
Switching to any task in the list of running task that has started
another activity (i.e. task.topActivity and task.baseActivity are
different) causes a crash.  I have tried the code above using both
task.topActivity and task.baseActivity but the results are the same...
force close.

- Crash Scenario 2:
Switching to specific tasks always causes a force close.  For example,
when I try to switch to the Calendar Task when it is "running" my
program always crashes.  However, I can successfully switch to Google
Maps, Home, Browser, and most others.

For the Calendar Task, I am getting ""
and the class name and "" as the package name.
When running the Eclipse De{*filter*}, I get a new tab that pops up in
Eclipse when executing the m_context.startActivity(intent); line...
The title in the tab says "ViewRoot.handleMessage(Message) line: 1583"
and in the tab is text in red that says "Source not found" and a
button that says "Edit Source Lookup Path"

I'm very baffled here and have not been able to find anything online
or in the google groups regarding this issue.  I hope that someone has
an idea of what I am doing wrong.  There are other task switcher
applications available on the Android Market that do not have this

Thanks in advance!

3. Is touch screen a mandatory requirement for Android phone?

4. Writing private apps for Android

5. support for flash on android? A road map?

6. Google Dev Phone unavavailable! will they extend ADC II deadline..who to ask?!

7. Is touch screen a mandatory requirement for Android phone?