logo
Tags down

shadow

How to make back button on WebView work in onBackPressed?


By : tarun tiwari
Date : October 18 2020, 06:10 AM
wish of those help I have some list items in drawer, one upon clicked opens WebView. In my MainActivity, I define WebView: , Here how my web view navigation works.
code :
public class MainActivity extends AppCompatActivity { 

    private WebView webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        webView = findViewById(R.id.webView);
        webView = new WebView(MainActivity.this);

        setContentView(webView);
        webView.loadUrl(...);

    }

    @Override
    public void onBackPressed() {
        if (webView != null && webView.canGoBack()) {
           webView.goBack();
        }
    }

}


Share : facebook icon twitter icon

why onBackPressed() always go back previous activity when i press physical back button?


By : Fasse
Date : March 29 2020, 07:55 AM
wish of those help dldnh is right. You can monitor for finish, or you can finish first activity after you start second activity.
code :
{
     Intent i = new Intent(this, com.second.class)
     startActivity(i);
     this.finish();
}
public void onBackPressed() {
       this.finish();
}

How to make it work the back button in android webview?


By : Oleksii Paziura
Date : March 29 2020, 07:55 AM
hope this fix your issue You have a WebView myWebView; declaration that is never assigned. To solve this you can change:
code :
WebView myWebView = (WebView) findViewById(R.id.wvBrowser);
myWebView = (WebView) findViewById(R.id.wvBrowser);

How use onBackPressed() inside fragment to back a webview?


By : Tim
Date : March 29 2020, 07:55 AM
Any of those help Use setOnKeyListener() on your WebView to listen to any event because onBackPreesed() is not the member of a Fragment
code :
        myWebView.setOnKeyListener(new View.OnKeyListener() {
           @Override
           public boolean onKey(View v, int keyCode, KeyEvent event) {
               if (event.getAction()==KeyEvent.ACTION_DOWN &&keyCode==KeyEvent.KEYCODE_BACK&&myWebView.canGoBack()) {
                  myWebView.goBack();
               }
               return true;
           }
       });

How to detect back button click and make webview go back


By : Dezzy Dodd
Date : March 29 2020, 07:55 AM
I wish did fix the issue. you need to make browser a class level variable so you can access it anywhere in your page.
code :
public class WebPage : ContentPage
{
    Xamarin.Forms.Webview browser;

    protected override bool OnBackButtonPressed()
    {

        base.OnBackButtonPressed();

        if (browser.CanGoBack)
        {
            browser.GoBack();
            return true;
        }
        else
        {
            base.OnBackButtonPressed();
            return true;
        }

    }

    public WebPage()
    {


        browser = new Xamarin.Forms.WebView();

        browser.Source = "https://myurl.com";


        Content = browser;

    }
}

Why won't the Back button work in this Android webview?


By : NataliaGarber
Date : March 29 2020, 07:55 AM
I wish this help you Having problems getting the "Back" button to work in webview. , Make mywebview a class instance variable.
Related Posts Related Posts :
  • With Scoped Storage introduced in Android Q, how am I supposed to develop a file manager app?
  • Can't resolve symbol android.support.v4.util.Pools in react-native-gesture-handler
  • Jetpack Compose: Could not set unknown property 'useIR'
  • SQLiteException: file is not a database while upgrading sqlcipher version from 3 to 4
  • What are best practices of implementing user login session in android application?
  • Button text not aligned center vertically in react native
  • "flutter (os error: no address associated with hostname, errno = 7)" only for android
  • How to catch platformException in flutter/dart?
  • Unable to connect to ADB
  • How can I test In-app updates in Android?
  • How to apply multiple generics in a function using Kotlin
  • Gradle DSL method not found: 'kapt()'
  • Android ADB: How to push multiple files, into an emulator?
  • How to run a multiple AND query with Android Room?
  • How do i fix the getting null location value from FusedLocationProviderClient in android
  • Which ad formats uses tinder?
  • How to perform delete api in retrofit
  • AWS AppSync Error - AWSMobileClientStore.get(String) on null object reference
  • Circular reference error in firebase with R8
  • how can I move views on the right direction in constrainlayout
  • Send Intent From Activity To Fragment
  • findViewById with PhotoView library problem
  • Removing the bottom Padding from a TextView while using HTML Format
  • Defining resValue conditionally in build.gradle
  • Is there another solutions instead of nested Recyclerview
  • Firebase + Flutter - Cloud functions onCall result in "unauthenticated" error from Android app
  • How to change textview text on cardview click?
  • App crash on opening document for some devices
  • How to fix Android compatibility warnings
  • Can't override android color resources
  • How add menu item's only for debug build type
  • RecyclerView with CardView Items, notifyItemChanged and shadow problem
  • Start activity without click on push notification's item
  • Checking if kapt uses incremental annotation processing
  • Show locations near user's location
  • How to hide a sub-mesh from SFB file in ArCore Android
  • There is always a default background on TextInputLayout in Android
  • 'List' is abstract; cannot be instantiated
  • A list in a list?
  • Wrong date returned from Location.getTime after 6 April 2019 (week number rollover)
  • socket connection using retrofit in Kotlin
  • Build Command Failed for CMake
  • Navigating between pages
  • Android : Support in-app updates result getting cancelled
  • What will cause Modifier 'abstract' not allowed here in RoomDatabase file using Android Studio?
  • Layout Expression - Ternary Operation for drawable value
  • How to have an Android Button with only a bottom border?
  • Actions on Google - Unable to test intent for app action on Android
  • Required single selection on MaterialButtonToggleGroup
  • AAPT: error: attribute android:forceDarkAllowed not found
  • Stop reloading previous fragment by using Navigation architecure
  • How to close the SimpleDialog in flutter after choosing an option
  • Sniffing SSL packets using Wireshark
  • Integrating google map api key in my android project
  • How to fix TextView position when text in it changes
  • Prevent 3rd party libraries to get my push notifications
  • Android bluetooth printer app works fine in debug mode but doesn't work in release mode
  • Unable To Get Particular Data From SQlite Database
  • Gradle + Cmake add unexpected Quotation marks when concatenate path
  • How to perform collection group query using document ID in Cloud Firestore
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk