How to stop app from auto-starting on Eclipse > Run - android

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.

Related

Do you want to terminate the process 'app' - Android Studio

Today, I update my Android Studio(4.1.1)
When I changes in my code and click on "Run App" then dialog shows Do you want to terminate the process 'app' and there are 3 options Terminate, Disconnect, Cancel.
Can you tell me what are difference in these because if click anyone then app restart.
Which option is best?
There is best option. What you have to select depends on what you want to achieve.
This dialog only makes sense if you have already started the app before. If you now run again the app Android Studio want's to know what to do with the existing running app as an there can be only one running instance of an app at a time.
Terminate
This will directly exit the app without saving and data or anything else.
The app process will just be terminated.
Disconnect
Close the connection between the debugger in Android Studio and the app as the debuggee.
Afterwards the app will continue to run just without attached debugger.
Cancel
Do nothing and just close the dialog
Command , (Setting or Preference)
Version Controll > Confirmation > "when files are created"
add or delete option check!!
I was having the same problem. Here is the simple solution that worked for me. Check Remember, don't ask again then press Disconnects. Lastly close your emulator and run the app again.

Android Studio: launch an activity of another app when debugging

Let's say I have two apps in an Android Studio project: "S_App" is an app that exposes a service, but doesn't have any activities and no GUI. "C_App" is a client app with a GUI that starts the service in S_App.
I want to debug S_App, but I don't know how to do so directly in Android Studio. Since the app itself doesn't do anything and has no GUI, I would need to start C_App to make it do something. However, if I "debug C_App" from Android studio then only C_App is attached to the debugger, but not S_App, which will consequently not hit any breakpoints.
I know you can manually attach a debugger to a process, but that is tedious to do every single time. Isn't there a way I can configure Android Studio so that it attaches the debugger to S_App but actually launches an Activity in C_App? I saw in the "edit configuration" dialogue you can choose a custom activity to launch, but this is strictly limited to activities within the app you're debugging apparently.

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.

Android Emulator Commands to call activity after phone boot is completed

I have developed and android application which is called after phone boot is completed. Now, for testing it I am using my android phone and every time I have to switch on and off my phone to test it.
Is there any command on for android emulator which switch offs and switch on it. I want to test it on android emulator. Let me know how can I do it.
I wrote such a boot service. Just close the emulator window, and reopen it to test the boot service.
But it's tricky: When you start the emulator window again, be carefull not to use the run button. If you use the run button, the application will be installed again, and the boot service is not active right after installation.
So you need to install the application, close the emulator, and then to open the emulator using the green button in the toolbar. If you can't find this button, just start any other Android project.
Your boot service will now be executed.

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