Hi.
I’m making a project for my tablet in android, and I have rooted it (super user).
Now I want to create a button from unity, to call a function from a Android Java library in .jar format.
This is the .jar code:
package com.arbit.apagadolibrary;
import android.os.Bundle;
import android.os.PowerManager;
public class EjecutaApagado {
static void Apaga() {
try {
Process proc = Runtime.getRuntime()
.exec(new String[]{"su", "-c", "reboot -p"});
proc.waitFor();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Then from my Unity app, I call it with the code as below:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PluginApagado : MonoBehaviour
{
private AndroidJavaObject javaClass;
// Start is called before the first frame update
void Start() {
}
public void ApagaAca()
{
javaClass = new AndroidJavaObject(".com.arbit.apagadolibrary.EjecutaApagado");
javaClass.Call("Apaga");
Debug.Log("apretado A");
}
}
But when I run the app, and then press the button linked to that script, the app closes. And doesn’t power off the tablet.
So, has anyone some idea what should I do? Is it a manifest problem?
I will appreciate so much the help.
Thanks!