I'm creating an Android kiosk application, a launcher application. The application shows apps that are allowed to be used by the user. I want to prevent the user from opening unwanted application (like recent apps, settings etc). So I've build a service (KioskService.class) which checks if the active activity is on the list of allowed applications. This is done with a Thread (So it checks even if another applciation is opened)
At this moment when an unallowed application is opened I return the kiosk application. What i want is that the previous activity is reopened.
So for example. When I open the Calender application (which is an allowed application) en then I open the setting from the Notification bar, the application needs to return to de Calender activity.
Thanks in advance,
T
First you will need root privileges, then try the below steps:
1) run a daemon service to constantly monitor which app is currently used by user. this can be achieved by getting the foreground app's package name.
For getting foreground app's package name use this code:
ActivityManager mActivityManager =(ActivityManager)this.getSystemService(Context.ACTIVITY_SERVICE);
if(Build.VERSION.SDK_INT > 20){
String mPackageName = mActivityManager.getRunningAppProcesses().get(0).processName;
}
else{
String mpackageName = mActivityManager.getRunningTasks(1).get(0).topActivity.getPackageName();
}
2) compare the package to your white list apps. If the current app is not in your list then kill it with the below code:
Process process = Runtime.getRuntime().exec("adb shell am force-stop packagename");
process.waitFor();
3) to prevent user navigating using notification bar or navigation button, you can kill the system UI process and make your own implementation of navigation buttons similar to floating buttons.
Shutting down other applications may cause a security issue for you.
The Android docs state
Your application runs in a secure sandbox environment, so other processes on the system cannot access your code or private data.
Ergo, trying to shutdown other apps from your own Service may not a viable option.
You could however bring your own app back to the foreground if another app is started?
Edit:
This looks like an interesting tutorial on how to build a kiosk app.
The approach is also interesting, as in your app starts on boot, so doesn't give opportunity for the user to launch another app,
What #Zain has given is a wonderful tutorial. I have gone through it.
If you want to disable other applications, you can do it with adb shell command.
adb shell pm list packages - will list all packages
and
adb shell pm hide com.the.packagename - will disable any package.
Related
I have a Bluetooth device that I can connect to an android phone, and I need to launch a specific application when a certain button is pressed on the Bluetooth Device.
So on press A--> Application A needs to be opened.
As of now, I am attempting to build an android application which can scan for and connect to the bluetooth device, with a set of built-in keymaps (A->Application A, etc), and the application would open up the application corresponding to the keymap, but this approach has its limitations in that I was not able to successively select buttons to transfer between apps.
Would there be a way to directly interact with the android kernal from BlueTooth to try to directly open up desired applications?
There should be a number of ways to get what you want, depending on your circumstances. We can provide more help for specifics if you post some of the code you're currently using to start the apps. It never hurts to review the basics of using Intents to start Activities.
Just guessing, but you may need to bring the requested activity to the foreground if it has already started and something else has focus.
Is it possible to have an App that works in the background and listens to when another app crashes on my device?
I want my app to notify my computer when it detects that the app I'm using on my device crashed or stopped. If so would what it need to listen too?
A very hacky way would be to write a native binary which monitored Logcat, upload the executable to your device using ADB and launch it using the shell account. Note that this is not an App though.
The Android shell user has enough privileges to view Logcat for all processes and perform network operations, so you could just scan Logcat for the tell-tale messages that indicate that an app has crashed, siphon out the stacktrace from Logcat and then send it over the local network to your PC.
This actually sounds like quite a cool idea. Might have a go at it building it myself :-)
I think you want to create Samsung's Smart App Manager . That track the crashes of all application and show notification to uninstall app or remove.
From Android doc : By default, the system assigns each app a unique
Linux user ID (the ID is used only by the system and is unknown to the
app). The system sets permissions for all the files in an app so that
only the user ID assigned to that app can access them.
Each process has its own virtual machine (VM), so an app's code runs
in isolation from other apps.
By default, every app runs in its own Linux process. Android starts
the process when any of the app's components need to be executed, then
shuts down the process when it's no longer needed or when the system
must recover memory for other apps.
Each and every android application runs in isolation from other apps. So any app can't track the crash log of other app.
The question is : How Samsung's Smart App Manager is doing.
I think samsung smart app only works with Samsungs devices. Root Permission is required to perform such type of action. Samsung's Smart App only have root permission in Samsung's devices.
If you are developing app for custom ROM or Rooted android device then you can otherwise you can't do.
When you upload your apk in the android developer console you have any options including errors options, then when the app crashed in some device they can send a report and you will can see it in de console...
I know it's not the best practice, but it is a requested feature (e.g. for business apps). When the App gets installed, I need to automatically place it on the home screen. I saw a lot of code on the internet, but all of the code only works on button click when the app starts. But I need to place a shortcut on the homescreen immediately after the app is installed and before the app starts. Is there a way I can achieve this?
PS: To make the question more clear: The app will be distributed without Google Play Store, so that's not an option.
Thanks for your help!
Best regards,
Robin
You can't run any code in your application before the user starts your application for first time during to restrictions since Android 3.1. Check this for more information
That's an optional feature of the Market app, not of the apps themselves. When designing an application , it does not receive a broadcast about itself being installed.
the first time the app launched can create it.
You can achieve that by creating a method in your main activity and call this method from oncreate and create a boolean variable andsave it in shared preferences
I want to get a notification if someone has performed an action in an android app from outside of the app. I don't want to make any (android) code changes. To do the actions I use the Chimpchat.jar, the .jar that the monkeyrunner tool uses.
To be clear: Can I get a notification or register listeners on components from outside of the app?
e.g.
Run my android app
My java application links into the device with chimpChat via the adb
The user touches a button
My java application gets a notification what was performed
=> am I able to get that information? If not, am I able to get the information on which position the tab was?
Hopefully it's clear what I want to do.
Thanks, soeren
If one publish's an app to the Android Market place and post-purchase/download tasks need to be carried out upon the purchase of the app by a customer through the marketplace, how can this be automated? For example, my Android app might require remote connectivity of some kind and so a username and password must be emailed out to them after they have downloaded my app + a record adding to my database..I know I must write a web service of somekind but cant think where to start :o does google checkout accommodate for such post-installation processes?
I am not sure if there is a post-installation callback that Android provides, but this sounds like something that can be done on first startup.
You could have a boolean in the application preferences that is used to determine if the your applications 'setup' has been completed. Any time the application is started, you check the boolean, and if they have already completed setup, you do a typical start, otherwise you prompt the user to go through the setup process.