Android Question Device Admin Application Screenlock

iatall

Member
Licensed User
Longtime User
Hi.. My Question is about device admin application.
I am developing device admin application.
I have go through device admin library and documentation as per below links:
https://www.b4x.com/android/forum/threads/device-administrator-library.19208/
http://www.b4x.com/android/help/administrator.html
I want that other than phone owner not able to disable my app without password.

Screenshot_2015-06-04-02-42-55.png


As per shown in above screen if user unmark my application checkbox manually from settings, i want to immediately show lockscreen.
So no one is able to disable it without password.
I found this kind of feature in one of the playstore device admin app. App Link.
Thanks in advance.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I want that other than phone owner not able to disable my app without password.
As written in the tutorial the user can always disable your app (and they can always uninstall it). This is how the API is designed.

The manager service will be started so you can do something when the user disables your app. I don't think that you will be able to lock the screen at that point as your app won't be allowed to call manager.LockScreen.
 
Upvote 0

iatall

Member
Licensed User
Longtime User
As written in the tutorial the user can always disable your app (and they can always uninstall it). This is how the API is designed.

The manager service will be started so you can do something when the user disables your app. I don't think that you will be able to lock the screen at that point as your app won't be allowed to call manager.LockScreen.

Thanks for reply Erel. means when user click on disable button within my app i able to show lockscreen.
I also want to know how to wipe phone data. I found below code on forum:
B4X:
Dim r As Reflector
r.Target = Admin
Dim rec As Object = r.GetField("rec")
Dim dm As Object = r.GetField("dm")
r.Target = dm
r.RunMethod4("setMaximumFailedPasswordsForWipe", Array As Object(rec, numberOfFailedPasswords), _
   Array As String("android.content.ComponentName", "java.lang.int")

Can you tell me what is "Admin" in this code? it shows me error:
java.lang.SecurityException: No active admin owned by uid 10077 for policy #4
at android.os.Parcel.readException(Parcel.java:1470)
at android.os.Parcel.readException(Parcel.java:1419)
at android.app.admin.IDevicePolicyManager$Stub$Proxy.wipeData(IDevicePolicyManager.java:1610)
at android.app.admin.DevicePolicyManager.wipeData(DevicePolicyManager.java:1089)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:216)
at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod2(Reflection.java:817)
at com.weatall.servicestatus._wipedata(servicestatus.java:862)
at com.weatall.servicestatus._service_start(servicestatus.java:529)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:158)
at com.weatall.servicestatus.handleStart(servicestatus.java:68)
at com.weatall.servicestatus.onStartCommand(servicestatus.java:53)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2703)
at android.app.ActivityThread.access$2100(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5018)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Is it same as AdminManager or else?
 
Last edited:
Upvote 0

iatall

Member
Licensed User
Longtime User
It is the AdminManager object. Have you added the wipe-data permission to the device_admin file?
Yes.. you are absolutely right. that was my fault.
Just removed comment line <wipe-data /> from project folder/Objects/res/xml/device_admin.xml
One can also be able to change password policy,encrypt storage or disable phone camera.
Leaving here for others.
Thanks for your help Erel :)
 
Upvote 0
Top