Android Webview - open my browser

Simão Lemos

i created a android webview but in my phone opens the browser after loading and I do not wanna

my phone is one samsung galaxy ace plus (android version 2.3.6) app created to android version +2.3.3

AndroidManifest.xml have:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="ivoclar.pack"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/android" android:label="@string/app_name">
        <activity android:name=".MainActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
</manifest> 

MainActivity.java have:

package ivoclar.pack;

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

public class MainActivity extends Activity
{
    /** Called when the activity is first created.
     * @param savedInstanceState */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        WebView myWebView;
        myWebView = (WebView) findViewById(R.id.webview);
        myWebView.loadUrl("http://gastro.hero.ch");

    }
}

layout - main.xml have:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

    <WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />

</LinearLayout>
Jibяaᴎ Khaᴎ

Simply add

    myWebView.getSettings().setJavaScriptEnabled(true);
    myWebView.setWebViewClient(new MyWebViewClient());

private class MyWebViewClient extends WebViewClient {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
         view.loadUrl(url);
         return true;
      }
   }

or within onCreate()

    myWebView.setWebViewClient(new WebViewClient(){
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
             view.loadUrl(url);
             return true;
          }
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Xamarin forms: How to check a browser is open successfully in my webview

Open external browser in webview?

Android Webview That Do Not open other browser after clicking login

Open link from Android Webview in normal browser as popup

LinearLayout onclick open WebView not browser

WebView open apps/default browser

Android Appcelerator Get URL from remote URL in webview and open it in devices default browser or a new webview

android WebView goes on the browser

Android open URL in WebView

How to open links both in an external browser and in-app within a WebView for Android

Is it possible to open only one specific link within a browser within a WebView android app?

Disable webview browser tester ( android )

InAppBrowser.open opens in browser instead of the WebView

Open Hyperlinks in JavaFX WebView with Default Browser

NativeScript WebView open url in default browser

webView in android open the website in web instead of webview

My cordova webview app is really slower than in the android browser on the same phone

open the link in webview Android Studio

Android WebView Behavior for open DeepLinks

Android WebView open Https website

Android webview launches browser when calling loadurl

Android webview: controlling which browser is used on redirection

Javascript function working in desktop browser but not in android webview

Android WebView Wrapper (In-App Browser) behavior

Android webview file browser opens but file not selectable

WebView: Inherit/get the function of Default Browser (Android)

Fileupload works in pc browser, but not in android webview

How can I open a URL in Android's web browser from my application?

How do I open any app from my web browser (Chrome) in Android, automatically?