Programmatically close a native application from another application - java

Basically, what I want to do is to close another app not created by me from my app. I haven't been able to find a solution but have learned that this is something many critizise as being a bad solution in general.
I do believe I have a good reason. What I want to do is to have an app that can recieve a file via PUSH OPP from another device that doesn't have an app installed on it. To be able to do this I have to disable the host-device's PUSH OPP application. I have to do this since I need to take over the default channel (12) for pushing files from the OS so that I have controll over the file-sending from the client. I can't use another channel since I can't have an app installed on the client and thus can't make it push the file via another channel. I know this probably is very bad practice but the device with the application will only be used for this specific application.
One way that seems to work is to manually disable the system's PUSH OPP application but this creates a hazzle when the user should install and use the app. They have to:
1. Install the app.
2. Every time they start the device they have to go into running applications and disable the standard PUSH OPP.
3. Run the app.
If I would be able to send a quit-command through my app to the native PUSH OPP app the default channel (12) would be freed up for me to use without the user having to go through step 2 every time. Is this even possible to do without root-access?

in your code, youcan use
system(“kill pid”);
get pid from /proc

Related

Difference between Service and PeriodicWorkRequest()

I have to work on a project Where I have to upload users' locations every 15 minutes. For that, I searched a lot and found Recurring work with PeriodicWorkRequest. But the problem is that the WorkManager might not work when the app is closed/killed per the answer given here. Then I found about Service in android.
So I want to know If I want to send users' locations every 15 min even when the app is killed then how to approach this?
If an application is Force Stopped, the OS cancel all the Job related to that application. This is not a WorkManager only problem. The OS interprets a Force Stop as an user request to the OS that they don't want this application to run anymore.
Even if you use JobScheduler or a Service, the application is gone. But a force stop should be a user decision.
Some OEMs have implemented in the past some changes to the Android OS so that a swipe out of an application from the launcher was interpreted as a force stop with all the negative effects on scheduled jobs. This is where the problems start.
WorkManager is this case has implemented some mitigation, but the application cannot do anything if it is force stopped till the user launch it again.
If have a problem with a specific OEMs, please open an issue on the Android issuetracker as this maybe a CDD violation. Google can contact the OEM and request that they fix the ROM. This is going to take time, in the meanwhile, you can take a look at sites like don't kill my app to understand what are the constraints on a specific device and use a library like autostarter to help the user to navigate to the right setting.

Android to always run activity

I'm making an Android app that act as an IOT host (I use serial communication and send it to Arduino). Is there a way to always set Android to run this activity (never sleep & always inside the activity)? It is important for it to not leave the activity since all the control and db access is done through it. So far what I've found already available is kiosk app in which it act as a launcher with limited app and such but none of the lock the android to an activity.
Thanks for answers & comment!
If you're curious :) The reason I use Android is that it needs a control panel UI and connection to a database, using RPI and other stuff would just get it to be more expensive.
there a way to always set android to run this activity (never sleep & always inside the activity)?
Not really. You are somehow looking for kiosk mode, or you can make your app acting as launcher (but it all depends on use case - if your app is only one on the device then this is all fine, otherwise you would need to put a lot of efforts to jail user)
it is important for it to not leave the activity since all the control and db access is done through it.
It sounds like your app architecture is just designed wrong.

How to block application launch in Android

I want to create an application in Android that will show the devices list of applications and then allow the user to select which apps they want to be restricted access to for a certain period of time.
I am aware there is an Android Application named "AppBlock" but i don't know how this works.
You select the app, the period of time and then it doesn't allow you to open the app.
You cannot actually block start of another application.
The only way that I see it is possible: you need to save the list of applications Info in your app that need to be blocked with the time when it need to be blocked. Implement a service that runs "forever" and detects started applications.
Refer to this answer about how to do it. On each detection you should check if application present in your database and if the time now says it need to be blocked. If it is - close the application. Refer to this answer for learning how to do it.
That is global architecture I think you should follow.
To Build App Block u need the following things
1-Accessibity services (AS)2-Forground Services (FS)
BY AS you will be able to stop activity that you have in your bloker list
FS will alive your application context that help to find block app

Android automatically download and install apk

we have our android application which is running in kiosk mode. We would like to have feature to automatically check for updates, install those updates and run application again.
We can use some android service for that (actually, that's preferable way).
Do anybody has idea how we can accomplish that?
Thank you.
When the user has activated the auto update option in Play Store, then your update will automatically installed once the user has Wifi. If the user hasn't set this option you can do nothing about that.
You can ping your API every time your app starts, and your API has to tell you whether there is a new version. With this information you can display a popup to the user which forwards him to your PlayStore entry. But the user must select to update your app, you can not automate this process.
What you could do: If you write an HTML5 app, or you have a WebView which loads content from the network, then you can do your magic updates by simple updating the sources on server side.

Can I build android executable right from my android application

How do I build a android executable from my android application? I am building an application where it would send some application data to another device. If the receiver is using my application, there is no problem. But if the receiver is not using my application or not aware of it, the application data means nothing to him, unless the sender informs him about it.
I wish to build a executable, right from my android application, which will run on receiver end. Receiver may not modify it but can run it easily.
Example of such use:
Video recorder or converter application which convert/record video on a custom format and play it. Now the sender wants to send that video to his friend. Unless he have installed such video, he can't access it. However if it is possible for the sender to create some executable to embed that video, which can run on any android device it would be great.
Even if it were possible, it is definitely not practical to compile an application on an Android device. Why not make the compiled application available in the Android market and/or your own URL, and then get the receiver to download and install it?
Like Elevine said, you should send a URL to App in Market instead of sending an app.
If google/Android evev allow sending app directly, Spammers, virus writers will love the "features". It is as bad as ActiveX plugin date of IE5,6.
BTW, I thought about this kind of approach before. One can have all the prebuilt jar, dex files ready and just want to zip them together with new data as resources, signed it with the right key. It is possible to do it in the phone. But you really don't want to do put your signing key in anyone's phone.
It is much better/simpler to just submit the needed data to a server in the cloud have sign the package there.

Categories

Resources