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.
Related
I'm starting to develop for android, and I'm having an issue about services. I did a lot of research about this, but couldn't find a solution.
I'm doing an app that collects RFID tags information. For that, I'm using a third-party middleware that handles the bluetooth connection to the RFID reader and other events (like connecting, reading, errors etc). So, my app creates a broadcast receiver that handles all the message and data intents sent by the middleware. For this part, everything's fine.
The problem is that I'm trying to start middleware service using the code below (provided by the middleware documentation), but it doesn't work.
Intent intent = new Intent("com.supplier.middleware.runner");
intent.setPackage("com.supplier.middleware");
startService(intent);
I'm currently using an Asus Zenfone MAX M1 (ASUS_X00HD) with Android 8.1.0. The documentation also describes a way to stop the service (which I must use when I close the app), and the stop service intent works. So, if I start the middleware manually and try to close programatically, it works fine.
After some days trying - unsuccessfully - to solve this, I tested my app with a Motorola Moto Maxx (which is Android 6, I think) and with a Samsung J1 (which is Android 5.1.1) and both smartphones worked fine: when I call the startService, a notification item appears; when I call stopService, the notification item goes away.
I also tried to use "startForegroundService" because of the Android 8, but no success either.
Is there a way to "monitor" the startService calls, so maybe I could track any error? Am I doing something wrong - or rather, am I not doing something that is important?
In Android 8.0 background service limitation.
https://developer.android.com/about/versions/oreo/background.html
You can use JobIntentService instead of intent service. It can work.
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.
I'm looking at the description for the Plan B app here: https://play.google.com/store/apps/details?id=com.lookout.labs.planb. It says it will start automatically after installation. How do you configure an app to do this?
Register to receive common intents. One especially suitable for your purpose is:
"android.intent.action.PACKAGE_ADDED"
You might also listen for other intents such as BOOT_COMPLETED, etc.
Edit: According to another Stack Overflow answer, You can't run your own application immediately after it's installed. You must register for other intents as I suggested. Something to note is that you app will require user permission to receive the BOOT_COMPLETED intent.
Update: As pointed out by zapl, post 4.0 you cannot do anything after install now until the user explicitly launches your app.
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).
i'm having a problem on android ICS (version 4) and broadcastReceiver . please help:
i'm trying to listen to a simple intent of network connectivity change . i've tried the next tutorial (with the broadcastReceiver defined in the manifest alone - the first part of the website ) :
http://www.xinotes.org/notes/note/1526/
on ICS , it doesn't capture any intent , and on any other version it works just fine .
can anyone please tell me what's wrong? do i need to add a new intent filter other than the one that listens to CONNECTIVITY_CHANGE ?
has google blocked listening to such intents on ICS ? are there any other new rules for ICS that have changed ?
i think that other broadcastReceivers also won't work on ICS using the manifest .
The sample code shown in that link may work, but it needs an activity. On Android 3.1+, an application is installed in a "stopped" state. While in that state, no BroadcastReceiver will work, until the user manually launches an activity from the application. The application will return to this "stopped" state if the user force-stops the application from Settings.
So, add an activity to your project, launch it once, and then see if your receiver works.