Javascript not running on Android 11 TvBox

Trevix

New member
In my Android 11 TvBox rooted, I prepared an action in Macrodroid, in order to connect to a not saved WiFI SSID, using Javascript.
This Javascripot was written by ChatGPT, since I am not proficient at all in this language:
List<String> wifiList = WifiManagerCompat.getScanResults(context); CharSequence[] wifiArray = wifiList.toArray(new CharSequence[wifiList.size()]); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("Choose a Wi-Fi network"); builder.setItems(wifiArray, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Connect to the selected Wi-Fi network String selectedWifi = wifiList.get(which); // Create a dialog for entering the password EditText passwordInput = new EditText(context); passwordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); AlertDialog.Builder passwordDialogBuilder = new AlertDialog.Builder(context); passwordDialogBuilder.setTitle("Enter Wi-Fi Password"); passwordDialogBuilder.setView(passwordInput); passwordDialogBuilder.setPositiveButton("Connect", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Get the entered password String password = passwordInput.getText().toString(); // Connect to the selected Wi-Fi network with the password boolean isConnected = WifiManagerCompat.connectToWifi(context, selectedWifi, password); // Display connection status String message = isConnected ? "Connected to " + selectedWifi : "Failed to connect to " + selectedWifi; Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); } }); passwordDialogBuilder.setNegativeButton("Cancel", null); passwordDialogBuilder.show(); } }); builder.show();
When I test the action with Jetpack Javascript, I receive the following error from the Macrodroid Log: "This device does not support the Jetpack Javascript Engine"
Using quickJs instead I get: "java.lang,NoClassDefFoundError:com.hippo.quickjs.android.QuickJS".
Finally, using JSEvaluator I get...nothing.

I don't really know what I am doing.
Any help would be appreciated.
Thanks
 

Endercraft

Moderator (& bug finder :D)
No wonder. This code is not JavaScript, it is Java (which is NOT at all the same thing!).
I don't think Android allows apps to connect to SSIDs the user hasn't connected to before.
 

Trevix

New member
The great AI bluff!!
Thanks for pointing this up. I wouldn't have known how to tell the difference. I will try something else.
I am pretty sure that in Android it is possible to code the choice of a WiFi and, entering the password, to connect to it. As a matter of fact I am already doing it in Livecode.
The reason why I want to do it with Macrodroid, is because Livecode does not handle at all TvBoxes buttons and fields.
Thanks anyway.
 
Top