I developed an app for displaying my HTML pages in android. I used webview to display my local html pages. It working fine.I need to use this same local html file to Google Glass. Is it possible? I used below code for android.
File f = copyFile(R.raw.index, "index.html");
File file = new File(f.getAbsolutePath());
String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(file).toString());
String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setClassName("com.google.glass.browser", "com.google.glass.browser.WebBrowserActivity");
i.setDataAndType(Uri.fromFile(file),mimetype);
mContext.startActivity(i);
private File copyFile(int resourceId, String filename) {
InputStream in = null;
OutputStream out = null;
File outFile = null;
try {
in = mContext.getResources().openRawResource(resourceId);
outFile = new File(mContext.getExternalFilesDir(null), filename);
Log.d("TestHTML", "output file" + outFile.getAbsolutePath());
out = new FileOutputStream(outFile);
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1){
out.write(buffer, 0, read);
}
} catch(IOException e) {
Log.e("TestHTML", "Failed to copy file", e);
} finally {
try {
in.close();
out.flush();
out.close();
in = null;
out = null;
} catch (Exception e){}
}
return outFile;
}