Programmatically press a button in another appplication's activity - android

Task manager on Motorola Droid3 shows a popup to ask the user whether to close a running application or not.
I need to programmatically answer "no" to that Activity. Is that feasible?
A more generic question: is it possible to "register" my application to catch the event of the opening of another's application activity and automatically press a button on that activity?
Thank-you

No, that is not possible. If that was possible, then each application could control device as if it was user. For example in this case such application could enable Mobile Data in Settings, but only system applications are allowed to do this.

Have you tried to figure out why the task manager is trying to close your application.
Make sure that you are not running any blocking tasks on the UI thread (like downloading or copying a file).

Related

Is there any way to stop app for desire period?

In android is there any way to stop specific app. Let suppose i want to stop the whatsapp so is there any possibility? I have tried Force Stop method but it does not works. Whatsapp automatically turn on after sometime.
Whatsapp like apps must have internal timers on the background service to restart it's services. So it invokes itself sometime later. Try to stop another basic app like calculator.
If you want to do programatically then you have to get permission for Administrative. And then your app will be able to kill other Apps. Like Greenify.
If you want to kill applications -> Use Greenify -> Auto Hibernate options. It will automatically hibernate applications after certain period of time.
Third way is root your phone and edit the permission of application. -> Remove permission of Boot to Turn on flag.

Android application which you cannot close

Is there any programming tricks that makes your application unclosable?
For example: You touch the back or the home button, but they don't do anything.
Or at least is there a way that your application blocks some applications to open?
I don't think you can stop user from moving your application to background unless it's some kiosk mode app. And the method to do that is to become device administrator and override all possible callback methods - home, back, settings, notification area etc.
If you just want to prevent your app from getting closed due to user activity you can show a persistent notification. This will allow you app to run in background even if user presses home button.
Make a launcher/Home screen app:
When users click the home button, your app will show.
You control ALL apps that can be started
On devices running android lolipop, you can use the screen pinning option available in your ROM.
NOTE: This is ROM feature, you don't have to do anything in your app.
See this great article about it.
yes its to get set the on backpressed method to.
moveTaskToBack(true);
finish();
Are you trying to hack in android OS ? Let me tell you that android apps are sandboxed, which isolates your app data and code execution from other apps.

Launch android app after start and block other apps

I'm facing the following problem. I want to make an android device to run only my application. All other apps and phone feautes should not be available to a user.
The reason why I want to achieve this is simple: I want to destribute devices with preinstalled application to my client but I don't want to let them use all phone featues.
This could work this way: just after android boots my application is launched automatically and than somehow all other staff is blocked.
Do you have any suggestions how to achieve that? Is it possible? Do I need to root a device?
I hope you get my problem. Any advice you can give will be greatly appreciated.
This is a bit crude way. But see if it is of any help.
If you create your application as a launcher it will start on boot(using system broadcast BOOT_COMPLETED).
Then you need to override all the three android buttons Home, back and recent apps.
To override back button you just have to override the onBackPressed() method.
For home button you will start a service which will run in background. This service will check if your app is in foreground or not. if not then it will bring it in foreground. so when the user presses home the service will sense the foreground app isnt yours and launch it.
But for this switching back of your app android takes approx 3 to 5sec. In that period of time you can display a warning text which will block the user from stopping the service from settings.Also if you remove the activity animations then it will appear seamless.
For recent apps button the above trick will do. If the user tries to close the app using this button your background service will sense it and launch your app.
so its the background service that does all the trick. if you some how stop the service or uninstall the app you are through :p

Disable Force Stop Button or Create a unstopable android service

I'm having the follow question how I'm disable Force Stop button, this is to accomplish one task of my project this is not for virus or malware or malicious things. I have to disable it for my service do not be killed because inside him it checks the time and create a file in a determinate time of system this is because my client wants to block the Android OS when it creates. I've already searched and appears if you start the with startForeground() method the force stop button became disable and another solution but i do not find much material is about create a system service if anyone know i will be happy. And if want make a suggestion for my work and works i will be very grateful. Thanks
You can't. The user is always able to stop a service on the phone, as he should be- its his phone, he can decide he doesn't want your app to run anymore.
The force close button appears because your program has entered a state in which it can no longer be executed sensibly (for instance an uncaught exception). Disabling the display of the close button will not solve your problem, you should debug your code.

Launch one activity from another

i just want to know how can i detect if the user opens an app so an activity of mine launches as well.
For example, the user opens the sms app and right after a kind of lockscreen appears.
You can create a service which will run int the background and you can use this API to determine which activity is visible. That's how many app lock works.
As far as I understand the Android system, it is not possible unless you are making a custom firmware.

Categories

Resources