Android studio Instant Run restarts whole app every time - android

I'm running Android Studio 2.3.2, gradle:2.3.2.
Every time I click Instant Run button the whole app restarts with this message in log:
Instant Run applied code changes and restarted the app. The app was
restarted since it uses multiple processes.
However, I do not use android:process anywhere in my code.
Moreover, there are no processes in Android Device Monitor or Android Monitor except main
one.

Related

Android 4.3: App spawns many processes on sync

On the Samsung S3 with Android 4.3, my Android app spawns new processes on every sync request using the SyncAdapter. The processes survive the "Force stop" button in the system's app settings and even an uninstall of the app. Only after a reboot, the processes are gone.
On an Android 4.3 simulator, this behavior is not reproducible.
On regular devices, our app is running in two processes (one for the app and one foreground service).
Has anyone heard of this beavior before? Might be a Samsung-specific issue. We have never seen this behavior on any other Android device.

How to build an IONIC 3 app runs as a 'foreground service'?

I am converting one of my own app written in Java with Android SDK to a new one based on IONIC 3. My old app starts automatically after phone boots up and runs as a foreground service.
I can see that there is an 'autostart' plugin in IONIC Native that I can use to start my app automatically after phone reboot (https://ionicframework.com/docs/native/autostart/)
However, I cannot see any plugin to let my app runs as a 'foreground service'.
I need to keep my app running as a foreground service so that it can monitor some physical button actions.
You can use Background Mode plugin after using autostart. This plugin prevents going to a pause state when in background, so that way you can still execute anything in your app (like it was in foreground).
I don't know where in your app do you monitor the button pressed, if it's in a specific view, but in Ionic probably you'll need to monitor it on app.components.ts.
Hope this helps

How can I debug an app without reinstalling it?

I have an Android app that needs to perform a certain task one time after it's installed, and then never again. It uses SharedPreferences to record that it's performed the task successfully.
In order to test this behavior, I run the task via Android Studio on a real device, connected over USB. The problem is, every time I run the app via Android Studio, it reinstalls. As such, it seems to lose its persistent memory (SharedPreferences).
It makes sense that the app's SharedPreferences should be wiped when it's reinstalled. But how do you run an app in the Android Studio debugger without reinstalling it and wiping the persistent memory? I looked at the Android docs for running an app from Android Studio, and from the command line, but none of them seemed to offer a way to run it with a debugger connected without reinstalling.
One option I see to accomplish this would be by closing and re-launching the app from the device itself, and then attaching the debugger in Android Studio to the app's process. But this would mean the debugger misses the first few seconds or so of the process's activity. My app's task gets done in the first microseconds. I should still be able to view the logs from those first few seconds, but not to have full debugger control.
Any ideas?
if you directly run app from android studio from same machine it will not reinstall it updates the app so your sharedpreference will not wiped it remain same. For more info about sharedpreferances http://developer.android.com/reference/android/content/SharedPreferences.html
for debug from first step you can use debug option which run app directly in debug mode (shift+f9)
https://developer.android.com/tools/debugging/debugging-studio.html

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.

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.

Categories

Resources