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.
Related
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
I'm developing a kiosk type application, running on a rooted device.
One feature of the app is that you must be able to download new versions of the app via wifi. However after running sudo commands to uninstall the app & reinstall the new one, we see the message 'unfortunately app has stopped'.
I'm trying to find a work around. The client does not want this dialog to be shown.
I thought of creating a second application to host on the device in order to display whilst updating and to close again after, but even if the other app is in the background, we would still be able to see the dialog which is against the clients wishes.
Any suggestions?
I doubt that the solution you thought of will work.
You receive the message saying unfortunately app has stopped because it is getting uninstalled while it is still running either in the background or not it doesn't matter.
What I would imagine could be a solution is sending out a command to quit the application you could use force-stop for this.
Take a look at these posts they might help you out
Stopping an Android app from console
Force Close an app programmatically
I am having trouble debugging some code in my DeviceBootReceiver (handles android.intent.action.BOOT_COMPLETED intent). I want to debug this bit, but how does one keep the debugger alive, when the device reboots? Is there any hack that anyone has come across for this?
What I want to do :
Start debugging app via Android Studio
Power down the device
Power up the device
Still be able to get the debugger attached to my app when it starts to handle android.intent.action.BOOT_COMPLETED intent
Any thoughts?
Open your device "developer options" settings;
Scroll down to "select debug app" and make sure your app is selected there;
Check the option "wait for debugger".
This will make sure that when your app is executed, for example when it receives a BOOT_COMPLETED broadcast, the debugger gets attached first.
Hope it helps.
You can re-broadcast the intent by yourself via adb shell:
$ adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
It takes about 30 seconds AFTER your device becomes available for interactions for android.intent.action.BOOT_COMPLETED to be broadcast. You have enough time to start up your application and enter debug mode manually
You might want to print a timestamp to your logcat when the android.intent.action.BOOT_COMPLETED intent is received so you have a better idea of when all this happens
While developing I wanted to test the situation where the system kills a service. This is because I'm loosing connection when communicating between the Android Wear and the handheld. And I think that it is related with the system killing some services.
Does anyone have a suggestion on how to approach this?
if you're developing in Android Studio while you are running your application in android wear side try to hit the kill button displayed in the console.
When you hit this button all the threads + services + activities from this app will be destroyed. If your service is of type "STICKY" it will start by itself after you kill your application.
As of 2020 we have to do it manually (since we don't have Android Monitor or DDMS anymore).
This was tested on Linux. You need root permission for the device (how to get root for an AVD).
Getting the PID (first number): adb shell ps | grep -i <package-or-part-of-it>
Killing the process: adb shell kill <your-PID>
cdlc's answer works, but another way is if you're developing in Android Studio you can go to DDMS: Tools->Android->Android Device Monitor and press the stop button there and you will also see a sticky service restart.
If you check the developer options on an Android phone, there will be an option to show the running services. Under that option you can choose to stop any service that is running.
Sorry if there is a simple answer to this, but I am new to Android development.
I have a service that starts on boot-up, and a UI that will attach to the service to configure the service. The problem is that if the Activity is defined in the AndroidManifest.xml it will automatically launch on the AVD startup, which is causing some issues due to the Service auto-starting, and the Activity syncronizing with the service. Does anyone have any examples of an Bootup service and activity?
One thing that my activity does is check to see if the service is running, if so it will bind to it, else it will start a service. (incase the service is killed post-boot)
Thoughts?
Go to the avd / sdk manager and just start the phone from there. it will load without your app appearing
window - Android avd and sdk manager - then select your phone and start
I haven't done boot up services myself but afaik your Activity should not start automatically and you should be safe as long as it's not spawned by your IDE. With Eclipse, if you're using it, you can modify launching from;
Right click on your project in Package Explorer.
Select "Run As" / "Run Configurations..."
After you have launched your application once there should be a launch configuration for your project under Android Application list.
Hope this helps.