Image from WebView - android

i m getting a photo from the web,but i see it very large..how could i see it with zoom out?this is my code for webView:
public class gavros extends Activity {
WebView browser;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.efimerides);
browser =(WebView)findViewById(R.id.webview);
browser.loadUrl("http://...");
}}

Checkout WebView's setInitialScale method:
http://developer.android.com/reference/android/webkit/WebView.html#setInitialScale(int)

Related

Open first Link searched against a keyword

I have 2 activities in my app, First Activity is simple editText and submit Button, When I press submit, it launches webView Activity and searches the keyword entered in the first activity. Now I want to open the first link Automatically in webview.
public class MainActivity extends AppCompatActivity {
WebView webView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = findViewById(R.id.webView);
webView.setWebViewClient(new WebViewClient());
String query = "firebase";// Get the text from EditText here
String url = "https://www.google.com/search?q="+query;
webView.loadUrl(url);
}
}

loading division of webpage in android webview

My webpage is divided in various parts instead of loading full page, i want to load a part of that page div id = map_canvas.
Below code is giving me full page but i want only one part map_canvas
public class Jetbill extends Activity {
public WebView myWebView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.jetbill);
myWebView = (WebView) findViewById(R.id.webview);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl("http://jetbill.biz/users/login.php");
}
}

Android prob to show pdf in webview

I am using android Webview to load a url to show a pdf file.
Here is my code:
public class TestProgectActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView mtWebView=new WebView(this);
setContentView(mtWebView);
mtWebView.getSettings().setJavaScriptEnabled(true);
mtWebView.loadUrl("https://docs.google.com/viewer?url=http://www.cbwe.gov.in/HTMLEditor1/pdf/sample.pdf");
}
}
It is working for the link "https://docs.google.com/viewer?url=http://www.cbwe.gov.in/HTMLEditor1/pdf/sample.pdf".
But it is not working for "https://docs.google.com/viewer?url=http://www.pancreaze.net/pdf/PANCREAZE.pdf". When I am firing this url through Webview it is showing HTML content in the WebView instead of the actual pdf file. Here is the screenshot.
What is problem in my code?

android phonegap webview

hello all i am very new to phonegap.. i want to webview into my application how can i add this? i've created same app. using android but how it can devleope using PHONEGAP?
private WebView mWebView;
//bla bla bla..
#Override
public void onCreate(Bundle savedInstanceState) {
mWebView = (WebView) findViewById(R.id.webviewHelp);
WebSettings webSettings = mWebView.getSettings();
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(new MyjavascriptInterface(), "HTMLOUT");
mWebView.loadUrl(strURL);
mWebView.setWebViewClient(new HelloWebViewClient());
}
public class MyjavascriptInterface {
public void showHTML(String html)
{
bla bla bla...
}
}
public class HelloWebViewClient extends WebViewClient {
#Override
public void onPageFinished(WebView view, String url) {
bla bla bla...
}
}
}
thanks in advance :Pragna
For your most basic PhoneGap app you should extend your main activity from DroidGap.
import com.phonegap.DroidGap;
public class Main extends DroidGap {
/** Called when the activity is first created. */
//private Button m_button;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
I would suggest checking out this link for a series of tutorials using Phonegap within the Eclipse development environment. Once you are setup on eclipse, you only need to overide a few lines of code in the Android Activity class to call your web pages. Phonegap takes care of the rest in terms of opening up a webview class and rendering your html within it. You will no longer to code that yourself (as you've done above). The tutorials spell it out quite clearly. You can also add your own custom JavaScript interface methods as well. Again that's described in the tutorials. Hope this helps.
In your case there is a need to Embedding Cordova WebView on Android here is link for it
Modify your main Activity as
public class MainActivity extends Activity implements CordovaInterface {
CordovaWebView cwv;
/* Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
cwv = (CordovaWebView) findViewById(R.id.tutorialView);
cwv.loadUrl("file:///android_asset/www/index.html");
}
And in your layout replace your webview with
<org.apache.cordova.CordovaWebView
android:id="#+id/tutorialView"
android:layout_width="match_parent"
android:layout_height="match_parent" />

Need help with android WebView

I am new to Android and java development. I create a WebView object in the OnCreate function. Now I need to be able to pass this same object to other functions in the code, such as the onOptionsItemSelected function. I currently have it where I just create a new WebView object in each function where I need it, but this slows down the code since it has to recreate it and such.
Something as simple as this?
public class MyActivity extends Activity {
WebView wv;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
wv = new WebView(this);
setContentView(wv);
#Override
public boolean onOptionsItemSelected(MenuItem item){
wv.doSomething();
}

Categories

Resources