Android Question Kiosk app - uninstallable

Liew

Member
Licensed User
Manifest editor:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
'Postion 1: android:testonly = "true"
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

'uncomment to set as home activity
'AddActivityText(Main,
'<intent-filter>
'   <action android:name="android.intent.action.MAIN" />
'   <category android:name="android.intent.category.HOME" />
'   <category android:name="android.intent.category.DEFAULT" />
'</intent-filter>
')
'AddApplicationText(<receiver android:name="anywheresoftware.b4a.objects.AdminReceiver2"
AddApplicationText(<receiver android:name="anywheresoftware.b4a.objects.AdminReceiver2"
        android:permission="android.permission.BIND_DEVICE_ADMIN">
    <meta-data android:name="android.app.device_admin"
            android:resource="@xml/device_admin" />
    <intent-filter>
        <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
    </intent-filter>

</receiver>)
CreateResource(xml, device_admin.xml,
 'Position 2:  Should I insert the android:testonly = "true" here so that the device_admin.xml will consist this line
<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-policies>
        <limit-password />
        <reset-password />
        <force-lock />
    </uses-policies>
</device-admin>

)
AddPermission(android.permission.MASTER_CLEAR)
AddPermission(android.permission.WIPE_RESET_PROTECTION_DATA)

In the kiosk app example, it was mentioned to add the attirbute android:testonly = "true" into
the {device_admin.xml} file which was created by the manifest editor file.
May I know the correct way of doing this.
If I insert that attribute in position 1 - I think this will not create the attribute in the [device_admin.xml}.
Whereas if I put it in position 2 - I will a have a compilation error as it is not a correct syntax.
Kindly advise.
Thanks
 
Last edited:

Liew

Member
Licensed User
Manifest added with testonly attribute:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:testOnly,"true")
SetApplicationAttribute(android:label, "KioskNew")

'End of default text.

'uncomment to set as home activity
'AddActivityText(Main,
'<intent-filter>
'   <action android:name="android.intent.action.MAIN" />
'   <category android:name="android.intent.category.HOME" />
'   <category android:name="android.intent.category.DEFAULT" />
'</intent-filter>
')
'AddApplicationText(<receiver android:name="anywheresoftware.b4a.objects.AdminReceiver2"
AddApplicationText(<receiver android:name="kioskapp.AdminReceiver2"
        android:permission="android.permission.BIND_DEVICE_ADMIN">
    <meta-data android:name="android.app.device_admin"
            android:resource="@xml/device_admin" />
    <intent-filter>
        <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
    </intent-filter>

</receiver>)
CreateResource(xml, device_admin.xml,
<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-policies>
        <limit-password />
        <reset-password />
        <force-lock />
    </uses-policies>
    
</device-admin>
)
AddPermission(android.permission.MASTER_CLEAR)
AddPermission(android.permission.WIPE_RESET_PROTECTION_DATA)

I had tested with the application attribute testonly added, I will not be able to uninstall the file after I used the
cmd line "adb shell dpm set-active-admin b4a.example/kioskapp.AdminReceiver2"
to make the app as an active admin app.
Why this happened as it was mentioned that if the app is a testonly app, it can be removed at any time.
Please reply
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
You could also try uninstalling it programmatically: https://stackoverflow.com/a/50257835
Actually I've got this working. Removing the app can be done by first running adb remove-active-admin, then uninstalling the app as usual. I'll write a tutorial and I'll post it on the forum in the next day or two.
 
Upvote 0
Top