I'm just getting started with java. I'm looking to open chrome to a specific page using a JNI from a button in the UI. I'm getting an error that the chrome file cannot be found. My questions are:
Runtime runtime = Runtime.getRuntime();
String[] s = new String[] {"\\system\\app\\Chrome\\Chrome.apk", "https://www.google.com"};
try
{
runtime.exec(s);
}
catch (IOException e)
{
e.printStackTrace();
}
and then the error
W System.err: java.io.IOException: Cannot run program "\system\app\Chrome\Chrome.apk": error=2, No such file or directory
Thank you in advance!
You are not using JNI, you are trying to execute an android as it were an executable using the Runtime.exec()
method. I don't think that will work in any case. You should try using Android functionality to open Chrome, not methods that would work on other operating systems like Windows or Linux. See this answer for some supported methods: https://stackoverflow.com/a/12013755/721855