I was digging this forum but couldn't find an answer to my questions ....
1, I developed SMS application by extending broadcastreceiver and everything is working great, the problem is that after the phone is sleeping for a while - the application is no longer working. So is broadcastreceiver considered a Service ? ( that will be killed by the Android after it's been idled for X minutes ).... because I don't have the "START_REDELIVER_INTENT" like I have inside a Service .... and I read some posts that said to use the AlarmManaget - but I don't understand why. ( the examples posts were not about receiving SMS though ... were in regards to calendars etc ... )
Bottom line - how do I fix this ? if I need to use a service to run itself after the android kills it - I don't understand how to convert my broadcastreceiver to be a service... ( because it's the only thing that needs to be running ... everything else is just settings and preferences ....)
2, When I install GOSMS for example, the android ask me - from now on which app would I like to work with as my default SMS program, what to I need to code in order to achieve this kind of notification to the end-users ? right now my application only receive SMS notifications ... doesn't send anything ...
Thanks in advance....
So is broadcastreceiver considered a Service ?
No, that's why it's called BroadcastReceiver and not Service.
Please see Application Fundamentals to properly understand the various key components of an Android application.
Also, if you have correctly registered your BroadcastReceiver's <intent-filter> in your AndroidManifest.xml then it will be 'woken up' to process Intents although as Jens mentions that may require you acquiring a WakeLock of some sort (and correctly acquiring/handling/releasing various resources during/after your task is accomplished).
Related
My application contains a BOOT_COMPLETED receiver like described in other threads here. It works perfectly until I changed my app into a system application. Now the Receiver does not trigger the event anymore.
Any ideas for this issue? I'm using Android Kitkat 4.4.2 on a Radxa Rock Pro. Compiled my own image to register the app as system application.
we need more detail to help you, post the code and the manifest, also debug log, in other hand you must use Log.i(TAG, "onReceive."); to know if the problem is in onReceive() or when trying to run the service class.
I'm triying to start a android service in android 4.0 when the device is booting, in boot time, but it's imposible , I had be used many codes, copy and paste. I had used code from here, stackoverflow of others examples and questions , but for me is imposible. I'm using android 4.0.1 in a table Acer Iconia A501. I put my code here. Somebody Can it try this code??? this is the page :This page please, it is easy
You need to register a broadcast receiver for the intent that is broadcast on startup. There is ZERO doubt that this is what you need to do.
See: BroadcastReceiver not receiving BOOT_COMPLETED
You need to do the same. Register a broadcast receiver and first make sure that you are catching the BOOT_COMPLETED event. Then its just a matter of doing a startService.
The problem is most likely in the Manifest. Check that you have exactly the right name for everything. Note the . in names like .MyBroadcastReceiver These are important. Missing just one thing will cause a problem.
Both the Receiver and Service definition must be perfect. Also check logcat and tell us what errors are there.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
BroadcastReceiver + SMS_RECEIVED
Lets say i have an application i want to launch every time my phone receives a specific text message, a keyword for example. Can i do this if my application is not running? What' s a good way to do it?
I have never tried this before and i want to run an application on one phone which will send a specific text message to another phone (done so far), then the 2nd phone would start an application when the message is received (after checking the message to see if its the keyword).
You need to write a BroadcastReceiver with the following intent filter
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
You'll need to create an AlarmManager for this with a BroadcastReceiver in order to receive data when your application is not running, I believe.
Although this may not be possible, as it could be considered a security risk to read the contents of a user's text messages... this would require some nasty permissions, and your users may not want to use the software because of that. Try taking a look at some of the Amazon free app of the day reviews to see how bad this can be for your app.
Other than that, you should be able to use the classes stated above in order to implement this. Let me know if this isn't clear and I'll try to expand upon it.
EDIT:
My mistake, a more appropriate way to handle this would be through a Handler with a background Service. I haven't personally used this myself, so I can't tell you much more than the documentation. Try reading the documentation and looking at the examples :)
So, we were coding an Android application in Eclipse, and we couldn't figure out why a class wouldn't delete. We removed it from the application completely, and it was still there. Then we found out that it was actually pulling in the information from another application. Does this usually happen?
EDIT: More information:
The problem only happened when we built on 1 of the three devices, the one that had the App it was pulling information from. On the other 2, it wouldn't run at all. The other App had a different name, signing key, and was a different project.
EDIT 2: It happened again. There is an app called SMS.apk, and the second is called 2012.apk. The class names are different, and the project names are different. There are no references to eachother in the files at all. But it was pulling in code from SMS to 2012. It worked, until we removed SMS, when we realized that it was using that code. At this point, we are a little worried we accidentally stumbled upon Skynet.
No, Eclipse does not do that. The reason this is happening is most likely because its an SMS app, so you're using broadcast receiver. Heres a tidbit from a helpful book:
One interesting characteristic of the BroadcastReceiver is that you
can continue to listen for incoming SMS messages even if the
application is not running; as long as the application is installed on
the device, any incoming SMS messages will be received by the
application
Source. pg. 273
1 . can we get any event when user tap/touch native application(i.e. messaging,contacts).
2 . i know that any application launch by intent in android, there is any way to know which application launch with launch of application.
Thanks
No, We can not get any event directly or by any receiver.
what I have figured it that it can not be done directly......
But there are two work around for this :
Start a service that will check top-activity always by this way can know what activity got launched and do whatever you do under this condition.
Catch the logcat, read the line, and you can easily get what event what even took place, and by using your required filters you can even do whatever you like :)
can we get any event when user
tap/touch native application(i.e.
messaging,contacts).
Not generally. Most of these icons are tied to their applications.
there is any way to know which application launch with launch of application.
This makes no sense to me, sorry.
I am agree with #K_Rapid's answer..
Check code of AppLocker
I hope you will got solution from that code...
For (1): what do you mean by 'tap/touch'? Do you mean when the built-in applications are launched, or when they're interacted with?
If you mean launching, you can listen to any intents being fired by the system by registering a broadcast receiver. If you set your IntentFilter to receive intents with CATEGORY_LAUNCHER, you should be able to see when the launcher starts applications.
See:
http://developer.android.com/reference/android/content/Intent.html#CATEGORY_LAUNCHER
http://developer.android.com/reference/android/content/BroadcastReceiver.html
If you mean interacting, I don't think you can do that.
For (2): I don't believe that intents remember where they were constructed, so I don't think this is possible. I could be wrong, however.