I want to make a lock screen application. When the phone is in the lock mode, it will turn off the phone while the USB is plugged for prevent other users from accessing the phone data. Does anyone know how to turn off Android devices programmatically so other people can't access the data while a device on the lock mode?
here's the code to lock the home button on the lock screen activity:
#Override
public void onAttachedToWindow()
{
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
It is impossible with the public Android SDK.
Yes it is possible,
Using making system application(Using firmware) not download application.
You can get the code for power off android device from AOSP.
This is what can provide you an insight of the OS you are working on , and not about developing an app that would run on any device, as you have not made OS's for them.
Just pull a branch of android , customize it according to your wish and in your mainfest remove the filters, permissions that don't allow you to do that, or add your owns. Now , you have to play with the battery if I talk of more depth.
But if you just want to trigger the click on power off then its far
simpler then.
Related
I was wondering if anyone had a relatively simple solution for us.
We created an app to be used by our clients on android devices that we give them.
We would like the client to only be able to use our app and have limited access to everything else (i.e. settings, email etc.) What is the best way to achieve this without using 3rd party apps.
Thank you in advance!
This may not help but the L preview has a task locking feature included that may be of some insight, I'm not aware of how it functions as yet
Task locking
The L Developer Preview introduces a new task locking API that lets you temporarily restrict users from leaving your app or being interrupted by notifications. This could be used, for example, if you are developing an education app to support high stakes assessment requirements on Android. Once your app activates this mode, users will not be able to see notifications, access other apps, or return to the Home screen, until your app exits the mode.
http://developer.android.com/preview/api-overview.html
Hope this helped
Suppress the Title Bar & Make Your App a Launcher
Root Your Tablet
Modify System Files and Settings to hide the soft keys
On the next link you can find the complete solution for the Nexus 7 (2012)
http://thebitplague.wordpress.com/2013/04/05/kiosk-mode-on-the-nexus-7/
simple Answer is:
Lock Install button with modify system settings.
Create your own customized-ROM and apply your requirement to that ROM.
more info, visit XDADavelopers
I am developing an app with launcher features (which is also Device Admin). In my app there is a button which when pressed opens the Google Play listing for my app so that users can update to the latest version. I am using the below code to achieve this :
try {
final String appPackageName = getPackageName();
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
}catch (Exception e){
e.printStackTrace();
}
Everything works fine, no problem here. Upon excecution of above code, the user is presented with this (pardon the Greek):
Due to the fact that my app should function as a launcher (in the sense that it shouldn't allow other apps to launch, and especially other launcher apps) the back button and search field pose a risk for me. In theory the user could navigate or search and download some other app other than my own as presented bellow:
So, my question is, is there a way to launch the Google Play listing of my app without the back button and search bar/icon? A page where the user can perform actions regarding my app and nothing more. No way to install other apps.
If someone comes up with an alternate approach which produces the same results, then by all means share your wisdom! But a Google Play listing of my app without the navigation/search bar on top would be the Holy Grail for me at this point! :D
Any help would be appreciated! Thank you in advance.
Some answers to anticipated questions. (Users that feel they have already read enough need not go past this point):
The app is targeted torwards a very specific demographic. It is a tool for bus drivers to print tickets using a thermal printer over Bluetooth and perform various work related tasks. The devices are not the drivers' personal devices but devices provided by their agency as work tools. The launcher features try to address an issue where drivers would consume their monthly mobile data using apps like Youtube e.t.c.
I have a Whitelist of apps that the user can freely launch. There is a service that checks which is the current app on the foreground and if it does not belong to the Whitelist, it immediately redirects the user back to my app (as there is no legit way to kill those apps on a non-rooted device). The problem with this approach is that if the app that was launced is a launcher app (let's say Nova Launcher) , then in the milliseconds that this launcher app was in the foreground before the service redirected the user back to my app, the launcher app had already presented the user with a dialog to pick the prefered launcher app for the device like the one below, thus disabling my app and gaining free access accross the device :
You can use in-app-updates to give updates to your app(but this supports API 21 and above)
Supporting API level 21 and above, the Play Core library now allows us to offer in-app updates to our users — meaning we can show that an app update is available whilst the user is within the context of our application
If your app satisfies the API level(ie minimum SDK is 21) follow this guideline to use in-app-updates
I am developing an android application and i need clear the data of another application upon clicking an button.
i.e.: if i click button name "gmail" in my app,the data should be cleared of that "gmail" app
doubt:
1.Is it possible?
2.Do we need to be rooted our android device in order to do this?
° because greenify works with root access to force stop the other app flexibly.
I know that greenify works without root but pop that "force stop" ui screen of each single app to do that action.
MY APP FUNCTIONALITY:
I just wanted to develop an android apllication named "anti-theft cloud apps"
simply if an thief stols our mobile then my app detects when he changes the sim or an unique code send by mobile owner through sms from other mobile and logouts all the cloud based applications like gmail,google photos etc to protect our data to be stolen ,so in order to do that i thought of clearing other apps data(like gmail) PROGTAMITICALLY to logout. Is it possible
This is not possible with stock Android. You can do it with superuser, access root/data/data/PACKAGE and clear its content. But as seen in comment, this seems like evil thing.
So I have been searching for a while and I would just like to know how to make an app lock or a phone lock with a press of a button. I want to install a custom button to lock my phone instead of using the phone lock button. I want to make my own custom program to do this.
I have researched many places but I cant find anything.
The API for locking the phone is not public in iOS. Hence, there is no way you can achieve this in iOS.
For Android, have a look at this,
How to Lock/Unlock screen programmatically?
There is no such a way to make your own custom phone lock button. In iOS it is not possible but if you want to do that in android just look this URL:
http://androidsourcecode.blogspot.in/2013/08/android-home-screen-widget-temperature.html
After a user opens my application I don't want them to be able to get out. So when they press the home or back button it doesn't let them exit the app. I know there are ways using a service to keep the app always running in the background, but I don't even want them to even exit.
Is this even possible, if so how? Without having to hack the kernel.
I know this sounds odd, but it is not for a commercial app, but for my lab, it will never be on GooglePlay. The tablets will be given to little kids and they will take a test on it, so I can't have them using youtube or anything else.
Related post: Android, How to make the task of the app unclosable? Only closable by task killing
The answer by CommonWare seems to indicate that kernel hacking is the only way, but is it?
Also I am using Android L.
there is no official support yet - there will be support with android L via the Task locking API
The L Developer Preview introduces a new task locking API that lets
you temporarily restrict users from leaving your app or being
interrupted by notifications. This could be used, for example, if you
are developing an education app to support high stakes assessment
requirements on Android. Once your app activates this mode, users will
not be able to see notifications, access other apps, or return to the
Home screen, until your app exits the mode.
https://developer.android.com/preview/api-overview.html
EDIT: as you said you use L this got obsolete - but I leave it here as a hint for others
said that - you are also able to get this kind of work without root today if you have to ( e.g. kiosk mode app on a certain hardware ). It is not simple - and no solution that works for all devices - but if you need it you can get it work with tricks like:
- reacting on home-screen intent ( and setting it as default )
- when you go to background - bring your self foreground again
- ..
It seems google has some thing called COSU for setting up single-purpose devices
Android 5.0 Lollipop introduced two new ways to configure Android
devices for a single purpose:
With app pinning, the device user can temporarily pin specific apps to the screen.
With lock task mode, a user can’t escape the app and the Home and Recents buttons are hidden. Additionally, lock task mode gives the IT
administrator a more robust way to manage COSU devices, as discussed
below.
and
As an IT administrator, you can configure Android 6.0 Marshmallow and
later devices as corporate-owned, single-use (COSU) devices. These are
Android devices used for a single purpose, such as digital signage,
ticket printing, point of sale, or inventory management. To use
Android devices as COSU devices, you need to develop Android apps that
your customers can manage.
from here
and there is a code lab for it here
for earlier versions of android here i founded How-To Create a Working Kiosk Mode in Android which shows some hacks for disabling buttons and restarting the application after boot and lock. note that most of these hacks, don't work on android 6 and later