I need a way or an ANE to force close an App

Hello!

I don’t know how to generate SWC files to create my ANEs, so how much does an ANE cost to force another App to close?
If exists some ANE for this, I appreciate.
I tested some ANEs that open the App and it works fine, but I didn’t get anything to close.

Thanks a lot.

What kind of app you are talking about? Do you mean NativeProcesses you launch yourself or any process in the Task Manager?

Sorry, I forgot about details.

Just need to force close an App in Android, I have the App ID (ex: com.something.app).

Do you mean terminate or minimise? Is the application your own application or are you attempting to close another running application?

Generally terminating applications is against the Android (or iOS) design philosophy. You should leave management of your application to the OS.

If you really need to end the application you could probably use an ANE to call finishAffinity() (or finishAndRemoveTask() API v21+) on the main AIR activity.

You could also try System.exit(0) though may not be best practice.

If you are looking to terminate another application I’m not sure that’s possible.

Hello!

I want to finish the process of another App.
I have two complex Apps, the second monitors the first. Rarely does the first freeze, without saying the reason in DEBUG, just freeze. (DEBUG also gets frozen).
Since the two are always in communication, the second App identifies that the first has frozen, but could not make it close only through normal Adobe AIR.

If the main App does not crash, I can close and reopen it using the open command (if it is open, it will close and then use the same command and it will open), but if frozen, the commands to launch a PACKAGE doesn’t work, and so the main app remains frozen.

So by normal means:
I tried closing the Main App from the second App via CMD (ANE), but it doesn’t work.
I tried the same way to open it, but it only works if it has not frozen.

So there may be or be created some ANE to be able to close another App.

Since both Apps are mine, so if you need to “put specific settings into their MANIFEST to sometimes capture the force close command”, that’s okay.

How does not seem to have a solution ready, if it does not exist, if it is possible for someone to create an ANE or a solution for it, what would it cost?

Thanks.

I’m not sure how you ended up with two apps instead of one
but in any case, even if you do own the app, you do not want to force close it by another app

first, it is not how it works on Android
there is an Activity Lifecycle for apps

you can not apply the same logic that you have with desktop apps
not only it is considered bad practice but it could also get your app banned from the store

second, one way you could tell the other app to stop (without getting your app banned from the store)
would be to send a message to the other app via Socket, RTFMP, etc.

but you can’t do that because in fact the app is frozen somehow

third, you’re trying to solve the wrong problem

you do not have a problem of closing another app

but you do have a problem of having a 2nd app running in parallel of the 1st app
and that 1st app freeze

even better, the 2nd app is here to monitor the 1st app, so in the end
you really need only 1 app that does not freeze


Now on the technical side, since Android 2.2 you can only close the background process of another app, not the app itself search for android.permission.KILL_BACKGROUND_PROCESSES

but that also why you have a problem, if you have a 2nd app monitoring a 1st app
the monitoring app should be a background process
but that is the 1st app that is freezing (and so is not a background process)

I don’t know what the hell you are doing but you are doing it wrong
and what you are looking for “closing another app” is just one more step in the wrong direction

Even if both your app were not freezing, you do not want to have 2 apps running in parallel

  • the user can see only one app screen at time
  • the back and forth between the two apps force both those apps
    in their own activity lifecycle to onResume() / onPause() at every switch
  • it will be simply much simpler to have 1 app

My guess is this, one app by itself run probably fine but it is the switching with another app that make it breaks because this app does not handle well the onResume() / onPause() cycle.

I would advise to ditch the other app, fix your app that is freezing and build/use only 1 app.

Simply put you have a debug and/or fixing bug problem,
you went all the way to create a 2nd app that monitor the 1st app with the idea that
“hey ho that 2nd app can probably force restart that 1st app when it crashes”
instead of simply fixing the damn app that is crashing.