Wear OS - How to automatically start app on device restart - android

I've created a Wear OS app. It has a service running in the foreground. I need to have the app always executing. When I restart the watch the app doesn't start executing again. How can I automatically relaunch the app?
It's my first app for Wear OS and I don't know how to search for this.
Thank you!

I'm not 100% certain, and it's a bad idea for an app to do in most cases. But I believe
https://developer.android.com/reference/android/Manifest.permission#RECEIVE_BOOT_COMPLETED
This will wake up your broadcast receiver so you can run some code, but as you discovered you are probably restricted against starting an activity.
https://developer.android.com/guide/components/activities/background-starts

Related

How to Start forced stop application after phone reboot

I was trying to get to know about the possibilities of getting success of Starting up a forced stop application after the phone reboots. So here is the scenario:
My app will not have any activity. It will be a service only app where no activity will be declared. So my goal is when ever the phone restarts, it will start up the service automatically even though the service is force stopped before the phone reboots. I am using Google Pixel 6 with Android 12 rooted phone. So I have all the necessary permission to achieve the task. I have tried couple of examples from stackoverflow. none of them works. They works only if you keep running the app before the phone reboots. It wont work if the service is Forced stop before the phone restarts. Any help will be appreciated.

Start service on app install

I have a service in my app along with activity classes. I want to start service as soon as app is installed. I have been able to start service on app launch,on device reboot, but not on app install.
Any idea if it is possible and if possible then how it can be done?
Thanks in advance.
Any idea if it is possible
Upon installation, your app is in the so-called "stopped state" and will remain there until something uses an explicit Intent to start up one of your components. Unless your app is a plugin for some other app that will do this, your app will not run until the user taps on the home screen launcher icon associated with one of your activities.

Service does not launch after install?

I have followed the tutorial here :
http://blog.sptechnolab.com/2011/09/14/android/starting-an-android-service-after-boot/
about creating a service, which is activating after boot of Android.
Anyway It practically never started.
I found in here : How to start a Service when .apk is Installed for the first time
that it is not anymore possible since Android 3.0+.
My question is :
How to start a boot service once installed ?
but how to start manually a service, since it does not have any visual elements ?
Add "visual elements", in the form of an activity.
You need an activity anyway, for:
Settings for managing the behavior of this service
Help and instructions for getting support
License agreement
So, write the activity. After the user has launched your activity, your manifest-registered BroadcastReceivers, such as your BOOT_COMPLETED receiver, will work again on Android 3.1+ devices.
In lates android versions you can launch on boot only when user manually started application.

Is it possible that a Service remains after the App which started the Service is deinstalled(!) from device?

For a better understanding:
Is it possible, that a service that was installed by an app remains on the device even after the app was deinstalled?
I can't seem to find it, but there was a malware that came with a service that showed spam push notifications even after the app was deinstalled. Was this Service a stand alone app that was also installed or a real 'service' that remained?
There are many threads about the question if it remains after an app or another service is stopped. Here I mean really deinstalled from the device.
Thanks in advance!
[edit: typo]
If service was in different .apk - YES.
If service was in the same .apk - NO.

Starting an activity from Broadcast receiver in android

I am trying to launch the Main Activity from a broadcast receiver. Can anyone guide me as to how I can do it? I always get "Process is Bad" message.
Thanks
Restart the emulator or just Kill the process that will solve this situation.
When using a real device, the only I found to fix this was:
Uninstall the app through Settings -> Applications.
Remove the battery from the phone (using the Android "Power off" menu did not work).
Turn device on again.
Install the APK again using adb install .
My app didn't show up in the list of processes running on the device (it's a BroadcastReceiver), so I wasn't able to kill that process.
See my answer here for more detail on what didn't work.

Categories

Resources