Tony,
Android apps are composed of individual components - activities,
services, broadcast receivers, etc. Their lifetimes are managed by
Android in response to events that are relevant for a particular type of
component.
http://developer.android.com/guide/topics/fundamentals.html#appcomp
A broadcast receiver getting an event does not mean that some or other
activity or a service should be started automatically, just because it's
a component of the same application.
After all, you wouldn't want all activities declared within your
application to be invoked at once, right? Same with other component
types. Each does its own thing, and they are glued together by the code
you write.
The issue with debugging a broadcast receiver is that Android limits the
amount of time that an application can take in its callbacks (broadcast
receiver's onReceive, activity lifecycle callbacks such as onStart,
etc.) If you take too long in the debugger, Android kills the process
thinking it's not responding.
My suggestion is to add logging calls (using Android's built-in log
class) to your receiver's onReceive, verify that does get called, and
take it from there.
http://developer.android.com/reference/android/util/Log.html
If you would like to notify the user that an SMS has been received, you
have two options:
- Start an activity using Context.startActivity - which is what you seem
to be trying to do, but which is considered in Android to be bad user
experience.
- Use a status bar notification, which would in turn launch the activity
to show the message:
http://developer.android.com/guide/topics/ui/notifiers/notifications.html
Finally, as for statics - this is a Java thing. Static members are, by
definition, independent of any particular instance of the class they are
declared in.
Hope this helps,
-- Kostya
11.09.2010 23:40, tony obrien пишет:
One more thing ... if I happen to be in the NetBeans IDE /
Debugger.... I can be at a breakpoint and (all of a sudden) its been
knocked out of debugging mode -- i.e. the App really has "died"
On Sep 11, 3:37 pm, tony obrien<tobsourcecode...@gmail.com> wrote:
Thanks, but I already HAVE such a thing in my Manifest...
I suppose that my BR intent *could be* lurking while my MAIN dies...
but then why doesn't the MAIN get REStarted when the BR starts
updating Main's (static) variables ? Main is *not* starting and so
its just as if the SMS was never received...
any ideas?
On Sep 11, 3:02 pm, Kostya Vasilyev<kmans...@gmail.com> wrote:
Well, all-you-gotta-do is:
Register your receiver in the manifest, like so:
<receiver android:name=".YourSmsMessageReceiverClassName">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
( Taken
from:http://developer.android.com/resources/samples/ApiDemos/AndroidManife...
)
Receivers declared in the manifest are active all the time, for as long
as the application is installed (and not disabled in the manifest). You
don't need to take any kind of special action for them to receive events.
In the onReceive() method of your broadcast receiver, you are free to do
whatever you like: such as starting a service to do some kind of
processing (I actually recommend this).
The application process will be started by Android as necessary.
-- Kostya
11.09.2010 22:25, tony obrien пишет:
I am hoping someone may respond and say … "Well, all-you-gotta-do is
Blah_Blah…" Is there a way to make the OS "not" clean me out of
memory? Is the answer to make the b-receiver a "service"? And is that
allowable in Android?
--
Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
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