Android :: Opening Local HTML File Via Browser Intent
Aug 31, 2009
My open source application needs to browse local HTML files on the SD card, and WebView is not enough because I need history and bookmarks. I wrote the following code. It correctly opens the browser, but fails to reach catalog.html and in fact it just opens whatever page was last browsed:
Uri uri = Uri.parse("content://com.android.htmlfileprovider/sdcard/ myapp/catalog.html");
Intent intent = new Intent(); intent.setData(uri); intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity"); startActivity(intent);
This should be very simple, but I can't find the answer anywhere. How do I load an html file (which I assume I keep in res/raw folder) into a webview? neither mWebView.loadUrl("file:///raw/about"); or mWebView.loadUrl("file:///raw/about.htmal"); works. What's the correct syntax or arrangement.
I don't want to store said file on the sdcard in this case. The file also cannot be storage directly in the apps local files directory. It needs to be in a subdirectory, so it cannot write the file using openFileOutput() and MODE_WORLD_READABLE.
The app may download files small files like pdfs and store them locally in a subdirectory. I would like to be able to have the user open these files if they have an app that can open them.
For example here is an intent for sending a pdf:
path being something like: /data/data/packagename/files/subdir/example.pdf
That intent will open a pdf viewer, but the viewer is unable to open the file. I assume this is a permissions issue. I tried Mark Murphy's suggestion here: http://groups.google.com/group/android-developers/browse_thread/thread/4e55d869213483a9/b7270078ac1a2744?lnk=raot of using Runtime.getRuntime().exec("chmod 755 " + fileName); but it didn't make any difference. He also suggested a Content Provider but I would like to avoid it if I can because it seems like a lot just to get this file over to another app.
If the content provider is the only option, do I have to save the file to the content provider or can I just use the content provider as a pass through to get it to the other app when I need to?
I have a swf file on the sdcard and I wrote a html file flash.html with the swf file embeded. The only way to open it now is: 1) open the browser 2) type in file:///sdcard/flash.html The swf runs fine.
But if use the code list below: Uri uri = Uri.parse("file:///sdcard/flash.html"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); It shows the error: The application has stopped unexpectly.
I also tried the following code using: WebView: WebView browser = (WebView) findViewById(R.id.list_web); browser.loadUrl("file:///sdcard/flash.html");
The Webview showed up, but the area should start the swf is empty. So is there a way to open the html through code? I also think if there is a way to open the android browser using ACTION_VIEW by a simple html then reset the URL to be "file:///sdcard/ flash.html" through code?
How to load simple html file present in sd mmc card from web browser. It is mentioned in the net that due to security reasons this is not allowed. Is there any way to access the file from sdcard? Tried modifying private String homeUrl = "file:///sdcard/index.html"; in BrowserSettings.java file but browser throws an error "could not be loaded".
I am developing a small application in Android. I come across a problem, and not sure whether it is possible in Android platform. I have some local html files. There is an Activity contains a webview, which is used to display these local html files. In some cases, I want to display a picture selected from phone into one of these local html files. Is it possible? Has anyone resolved such problem? I appreciate any of your replies.
I've used the code from the PDF rendering question http://stackoverflow.com/questions/2883355/how-to-render-pdf-in-android And it works! Props to the answerer, but my question is about doing that same thing but also sending a keyword to search in the pdf. I have no idea how to do this, should I set a flag?
I'm having a struggle understanding why my intent is not working. I basically just copied paste from other examples in my code that work perfectly like this. Here it is:
Intent addIntent = new Intent(v.getContext(), thenNnowMode.class); Bundle w = new Bundle(); String activityName = "addPic"; w.putString("activity", activityName); w.putParcelable("bitmap", selectedDeviceImage); //a.putString("id", picId); addIntent.putExtras(w); startActivity(addIntent); finish();
The intent is opening a different class called thenNnow.class instead of thenNnowMode.class and I have no idea why this is happening. I've tried sending the intent to open other activities other than thenNnowMode but it always opens thenNnow. Am I missing some silly syntax mistake? It's so strange, its the same code. I am not sure if it's relevant but the thenNnowMode class uses the device camera
I just want to know what intent am I going to use to open a mail client. I can open the "compose view" of the mail client but I cant find an intent to open the "inbox view" of the mail client. The same thing for opening the "mail" application from android device. For example, from my application, I want to call "mail" application. What intent should I use for it?
How come this is the only file manager on the market (that I've found... I went through quite a few) that can open an HTML file from your SD card? I was a loyal user of Estrogen until I found that it couldn't.
Why a inline webview into which I pass a URL is now opening a browser session for the URL instead of populating the in app webView? It works on the emulator perfectly but a physical device shows the browser. The emulator is build CUPCAKE 150240 The device is CRC1.
I'm trying to make test-program that opens a website by pushing a button. I have made a listener and everything, my problem is just that, the url-opening-script makes an error and tells me "Uri cannot be resolved".
Here's the script I use to open up an webpage:
I have the import android.app.Activity;, import android.content.Intent; and import android.content.ContentUris; (maybe the last one isn't needed) so I can't find out what's wrong...
I hope someone knows what I've done wrong, or forgot to import...
We have one html page whose backgroud is an image(1024px*600px) with no-repeat. We displayed it in Browser rightly on 1.6 HVGA(160) and WVGA(240) emulator and scrollbar displaed on both sides. But we got different result when testing on 2.1 HVGA(160) and WVGA(240) emulator. On 2.1 HVGA（160）, the background image is scaled smaller and we saw large wide margin on the right. On 2.1WVGA (240), There are two margins on right and bottom sides. There is no scrollbar displayed on 2.1. And we put few small element in our html page.
Like the title says, I am thinking about developing my own browser for Android devices.
My first thought is to know what kind of possibilities I have, before I begin creating my software architecture. Are there any (open?) Browser Engines you could include into your library and reuse them? (There are some unknown browsers in the Android Market and I can't imagine they implemented the parsing).
Furthermore: If there IS something like I've described before, is it possible to modify (or "fine tune") the render methods? This is one of the most interesting points I guess.
And to end this question and catch the else-case: What would be the alternative way to begin? [I guess this is not only interesting to know for mobile developers, also for desktop software developers]
Abbreviated version of this question: I want to develop my own Android Browser. How to begin?
Can one use an Android phone to access basically local (think intranet for example) web servers to view pages? I ask this question because some cell phones with some phone network appear to use a special server to funnel cell phone requests thru and that the server offloads from the browser part of what a browser normally does. I get the impression that the Opera mobile browser works this way.I want to talk to local devices that serve web pages and connect directly to them from phones. Does the Chrome browser in Android have the full functionality that Chrome has on a PC? Can it parse HTML, do XMLHttpRequest, and otherwise act like a modern browser?
I wanted to be able to use my Google bookmarks on my Droid. I found a program that imports them to the phone, but it replaces everything and I didn't want all those bookmarks in my browser. I exported my Google bookmarks to a HTML file and stored it on my SD card in the download folder and named it bookmarks.htm. I then went into the Droid browser and typed the following URL: content://com.android.htmlfileprovider/sdcard/download/bookmarks.htm
I then created a bookmark of the link.
Now, I open my browser, click on the bookmark, and all my Google Bookmark sites are displayed as links in order listed under their categories.
The company I work for produces allot of video and we want to target as many devices as possible, but the question came up of what does the Android do? I personally own an Android based phone running 2.1, but I can't seem to get the HTML 5 tag to work. Even when I can trigger the browser to playback the video it just throws a notification error that it can't.Are there guidelines to producing Android/HTML 5 compatible videos? Is it truly supported?
I have a bunch of pages that render normally on the Android 1.6 native browser as well as on the iphone Safari browser, but are heavily zoomed out and small by default on the Android 2.1 native browser.The pages are zoomed out by about 4x making them appear very small.Of course I can manually zoom in, but I dont want the users to have to deal with that.Anyone else face this issue, and is there a fix for this that doesn't break how it works on other browsers?