Closed roberthobblebottom closed 3 years ago
If you just want to request your App to be the selected Kiosk mode App, using robot.requestToBeKioskApp()
is enough, but the meta-data
is necessary also for that.
<meta-data
android:name="com.robotemi.sdk.metadata.SKILL"
android:value="@string/app_name" />
<meta-data
android:name="com.robotemi.sdk.metadata.KIOSK"
android:value="TRUE" />
After that, the system will pop up a dialog box after the method is called. After clicking the "Allow" button, your skill will become the currently selected Kiosk skill.
Actually onRequestPermissionResults
is not the callback method of temi SDK and it belongs to Android SDK, you should implement OnRequestPermissionResultListener
to listen to the permission granted status. More information for the temi permission please check the documentation and the sample code.
We want that there is only one App could modify the system settings at a time so Kiosk permission is required for that.
hmm,
My AndroidManifest.xml have do have such xml codes already and I have already implemented OnRequestPermissionResultsListener and also the add and remove statements.
I put my codes above in MainActivity onResume, I did put in my MainFragment onCreateView before. Maybe there is something wrong with the placement here. Those codes gave me double or triple Kiosk permission requests on the very first start up of the app on temi.
I wonder if Settings permission works with ActivityResultLauncher. I used this to get the external storage permission.
Okay enough of my random thoughts and guesses, I will try to read the sample codes even though Im working with Java.
Edit: Am I right to say that when my app closes completely, KioskMode is then set to false?
It seems to me after shifting all of the permission to onRobotReadyListener and arranging the if else blocks of each permission in a certain way but I don't understand why it will request for KioskMode twice. Any help in this regards?
@Override
public void onRobotReady(boolean isReady) {
if (isReady) {
try {
final var activityInfo = getPackageManager()
.getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
robot.onStart(activityInfo);
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
robot.addOnRequestPermissionResultListener(this);
Log.d(TAG, "MainFragment onCreate kioskMOde and isSelectedKioskApp Check: " + robot.isKioskModeOn() + robot.isSelectedKioskApp());
Log.d(TAG, "onCreate: " + (robot.checkSelfPermission(Permission.SETTINGS) != Permission.GRANTED));
//Permissions checking and request codes/
if (robot.checkSelfPermission(Permission.SETTINGS) != Permission.GRANTED) {
robot.requestPermissions(
new ArrayList<>(Collections.singleton(Permission.SETTINGS)),
Permission.GRANTED
);
} else if (!robot.isKioskModeOn() || !robot.isSelectedKioskApp()) {
robot.setKioskModeOn(true);
robot.requestToBeKioskApp();
Log.d(TAG, "MainFragment onCreate kioskMOde and isSelectedKioskApp Check: " + robot.isKioskModeOn() + robot.isSelectedKioskApp());
} else if (ContextCompat.checkSelfPermission(this,
Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED)
requestPermissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE);
}
}
Im just going to leave this bug as it is in my code, it really can't be fixed on my part after many hours in this.
For your questions,
You will receive the robot ready event immediately when you invoke addOnRobotReadyListener(this)
, so consider moving addOnRobotReadyListener(this)
to onCreate()
for reducing invoking addOnRobotReadyListener(this)
for receiving less robot ready events. Because the dialog box for requesting permission will impact the lifecycle of your Activity.
No need to disable the kiosk mode if you just want to back to temi Launcher for something for a short time and you can use Robot.getInstance().startPage()
instead.
Thank you so much for 1) no more double kiosk permission request.
I could have also use 2) too but I think my stakeholders may want an actual exit function.
Why doesn't robot.setKioskModeObn(true) works when boot up my app?
Also even though I have granted Settings permission already, it also goes into the else if block as it is not granted. Also onRequestPermissionResults didn't run in my code.
It is frustrating that these codes seems glitchy.
Is there a reason why I have to access the goToSpeed and toggling of the billboard through this this kiosk permission? Why can't it be just Settings?
Is this a bug? Or some internal settings I did not configure properly?