Start Android Service on boot time Android 4.0 - android

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.

Related

how to make custom incoming call screen in Android in android kitkat

I tried many ways , but didn't work on kitkat or lollipop
I need broadcast receiver with code that can answer the call by a button , please
Sadly, you can't answer the call. This is a system permission that you can't acquire.
It is system permission and you shouldn't do it, but I found nice solution to this. You can use Intent.ACTION_MEDIA_BUTTON and send it once to answer a call and send it twice to reject it.
Android emulate/send ACTION_MEDIA_BUTTON intent

Android Boot Completed Receiver doesn't work on system app

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.

Is broadcastreceiver considered a service?

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).

Does Eclipse or Android usually pull in other code?

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

Get event on launching the native application

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.

Categories

Resources