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.
Related
When a mobile app is closed it generates an event that can be captured.
// trap app shutdown event
Titanium.App.addEventListener(‘close’,function(e)
{
Ti.API.info(“The application is being shutdown”);
});
I would like to create an event handler that pops up an alert to ask "Are you sure you want to quit the app", just in case someone presses the wrong keys...
Is it this possible and can you cancel the shutdown event?
You can do it in Android only. It's not possible on iOS.
Further, on Android, this can only be done if app is closed by pressing back button, not from task manager.
Here's how you do it on Android:
<Alloy>
<Window id='win'>
</Window>
</Alloy>
// for Ti SDK 6.0.0.GA or above, you need to use this code
$.win.onBack = close;
// else use this code for SDK 5.5.1 or below
$.win.addEventListener('androidback', close);
function close() {
alert('Do you want to shut down app????');
}
Read about the androidback event here
And the ticket which added the above breaking change:
https://jira.appcelerator.org/browse/TIMOB-19919
Short answer is: No, you cannot
You can track events related to the lifecycle of the application but you cannot prevent that from happening. Without getting into the bad user experience that this could be let's talk about a user scenario will look like.
If you are using your Android phone and you want to close an app and it just keeps asking you if you are sure you want to close it, the programmer ignored the Yes action and keeps the app running. How insecure and annoying will this be?
I managed to resolve this problem by firstly hooking into the Android back event and secondly by using bencoding Alarm Manager to run the background code constantly. That way, if someone shut the UI down, the app continued to run in the background regardless.
I learned that following is Overview screen.
I clicked the dialer and dialed a number and then swiped the dialer to the right.
But still the call is on like this.
How is this done?
I am a newbie to Android programming. I am thinking if they had used a back ground thread or a separate service or something else, so that it is never killed accidentally. How is this done?
Please help me. Thanks.
I believe it is using the Android foreground service. You can checkout how to run it in the doc:
https://developer.android.com/guide/components/services.html#Foreground
The difference of foreground from background service is when phone is low on memory, system will not automatically close it to release memory, it should be closed manually by user, which is why you need to have a notification as a way for user to close it when you first create it.
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
I am facing a big issue in android service and I searched more than 3 days but I didn't get any solution so please help me.
Currently I am working on a lock screen based service project that make your phone more secure means no one unlock it easily that's work fine but the main problem is that if my application is forced close by user via task manager then it also force close the service of my app then after that, when user press lock button to unlock his phone then it directly open home screen.
Is there any way to restart my application service after few second or at the same time or at the time is user press power button.
In my app I am also disable default lock screen that,s why if my app is force close then after that no security is worked for phone it directly show home screen that's not good, if my app is forced close then at least it enable default lock screen.
Any one who have idea about this please help.
Thanks in advance.
In Android, it's usually not recommended to start the service on it's own even if it is explicitly killed by the user. I don't think if there is a way to start the service again if the user goes into settings and kills it. BTW did you specify the service as remote?
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).