Search in sources :

Example 1 with FileSystemFileConnection

use of org.microemu.cldc.file.FileSystemFileConnection in project J2ME-Loader by nikita36078.

the class MIDlet method platformRequest.

public boolean platformRequest(String url) throws ConnectionNotFoundException {
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        if (url.startsWith("file://")) {
            FileSystemFileConnection fileConnection = (FileSystemFileConnection) Connector.open(url);
            intent.setData(fileConnection.getURI());
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            fileConnection.close();
        } else {
            intent.setData(Uri.parse(url));
        }
        ContextHolder.getActivity().startActivity(intent);
    } catch (ActivityNotFoundException | IOException e) {
        throw new ConnectionNotFoundException();
    }
    return true;
}
Also used : ConnectionNotFoundException(javax.microedition.io.ConnectionNotFoundException) ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) IOException(java.io.IOException) FileSystemFileConnection(org.microemu.cldc.file.FileSystemFileConnection)

Aggregations

ActivityNotFoundException (android.content.ActivityNotFoundException)1 Intent (android.content.Intent)1 IOException (java.io.IOException)1 ConnectionNotFoundException (javax.microedition.io.ConnectionNotFoundException)1 FileSystemFileConnection (org.microemu.cldc.file.FileSystemFileConnection)1