Showing posts with label Display image in WebView. Show all posts
Showing posts with label Display image in WebView. Show all posts

Saturday, March 9, 2013

Display image in WebView

If you are so lazy as me! Display image in WebView is a good choice.

Java Code:

package com.image.webview;

import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.webkit.WebView;

public class MainActivity extends Activity {

WebView webView;
String imagePath = "/sunil.png";

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);

webView = new WebView(this);
setContentView(webView);

String fullUrl = "file://"
+ Environment.getExternalStorageDirectory().getAbsolutePath().toString()
+ "/"
+ imagePath;
webView.loadUrl(fullUrl);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);

}

}

Need To add INTERNET permission.


 Cheers Guys!!

 

Copyright @ 2013 Android Developers Tipss.