Android webview experienced a blank page after completion of Facebook share button

Whenever I open the webview and click on the Facebook share button, it works perfectly. However, after the share is completed, it leads me to a blank page.

Sometimes, instead of a blank page, it actually shows the original page. But most of the time, it's a blank page.

I really want to ensure that the page with the share button is always displayed.

Below is the code snippet:

   //in onCreate.
    String Url = //my url//;
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(true);
    view = (WebView) this.findViewById(R.id.webView);
    view.getSettings().setDomStorageEnabled(true);
    view.getSettings().setSupportZoom(true);
    view.getSettings().setBuiltInZoomControls(true);
    view.getSettings().setUseWideViewPort(true);
    view.getSettings().setJavaScriptEnabled(true);
    view.getSettings().setAppCacheEnabled(true);
    view.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    view.getSettings().setAllowFileAccess(true);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        CookieManager.getInstance().setAcceptThirdPartyCookies(view, true);
    }

    view.loadUrl(Url);

    view.setWebViewClient(new myWebViewClient());
    view.setWebChromeClient(new ChromeClient());
    //

    private class ChromeClient extends WebChromeClient{

    @Override
    public void onProgressChanged(WebView view, int newProgress) {

        MainActivity.this.setProgress(newProgress*1000);
    }
    public void onCloseWindow(WebView window){
       super.onCloseWindow(window);
    }

And here is the JavaScript code snippet:

    function fn_facebook_share() {
    var url = //my url//;
    var title  = "${VideoModelDetail.title}";
    var user_nm= "${VideoModelDetail.user_nm}";
    var univ="${VideoModelDetail.univ_cd_nm}";

    FB.ui({
          method: 'feed',
          link: url,
          name:title,
          caption:univ+" | "+user_nm,
          description:'text',
        }, function(response){});
}

Answer №1

To resolve the blank page error caused by a JS script failure during redirection from OAuth login to authorization acceptance, consider relocating your webview to an XML layout file. This issue can be addressed by moving the webview into the XML layout. I encountered a similar problem with my Android app, where the problem stemmed from Facebook login JavaScript opening a new page in a new window.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using a slider in Cordova application

Currently, I am in the process of developing an app using Cordova. However, I have encountered an issue with the slider feature. HTML <body> <div id="slider"> <div id="custom-handle" class="ui-slider-handle"></div> </di ...

Issues with AJAX calls in PhoneGap app after updating Android from 2.3.3 to 4.0.3

My latest project involved creating a mobile application with: jquery mobile 1.1 jquery 1.7.2 cordova/phonegap 2.0.0 This app makes AJAX post requests to a remote server, like so: $.ajax( type: "post", cache: false, timeout: 30000, url: "http://"+ user ...

restore the HTML element to its initial position after being moved

I am utilizing document.getElementById('Droping1').style['-webkit-transform'] = translate(0px,'+Ground+'px)'; in order to relocate an HTML element. How can I return it to its original position for reusability without t ...

Adding ng-add & npm link - A guide to mocking the npm registry

I'm currently working on a collection of schematics for @angular/cli and I want to test it locally. Is there a way to test the ng-add CLI feature locally? When I link my project using npm link and run ng add myFeature, @angular/cli attempts to downl ...

Arrange a JSON array by searching texts initially, followed by sorting the remaining results in alphabetical order

I am looking to sort a JSON array in JavaScript based on a search text. The sorting should prioritize items that match the search text at the beginning of their value, followed by alphabetical sorting for the remaining results. Even if the search text is f ...

Tips for removing a Facebook post or comment from within a PHP script

I've been struggling to delete a post or comment from my Facebook feed, even after following the Facebook documentation. Below is the code snippet I used for the delete request: $postid = "2512732972186856_2511181632341990"; $token = getUserAccessTo ...

Custom dropdown feature in Vue-tables2

Is there a way to customize the select dropdown style in vue-tables2 table? I am trying to change the entire template of the dropdown, not just add CSS classes. My custom template includes additional elements like span and div tags that need to be incorpor ...

Tips for waiting for an HTML element to load in a Selenium JavaScript testing script

I'm struggling to find a way to wait for an element to load in a javascript selenium test script. The closest thing I've come across is until.elementLocated, but it seems to throw an immediate exception. Is there a method to delay throwing the " ...

Utilizing Object-Oriented Programming in JavaScript for Image presentation

I am struggling to show an image using a <button> element and it seems like there is an issue that I can't figure out. Despite reading various resources on Javascript and OOP, I am still unsure if I have implemented the concepts correctly in my ...

Creating camera shake in Three.js: A beginner's guide

I've been searching for hours online and I can't seem to figure this out. Is there any way to achieve this? If so, please share the steps with me. I found a code snippet but I'm unsure how to implement it properly. Can someone guide me on ho ...

When I resize the screen size, my multiple item carousel in Bootstrap is failing to adjust and collapses

Whenever I try to resize the output screen, the carousel collapses and the last few items disappear. I really need the carousel to stay intact even when resizing. Can someone please assist me with this issue? Link to my CodePen ResCarouselSize(); $(w ...

Troubleshooting Firefox HTML Positioning Problem (Functioning Properly in IE and Chrome)

After implementing the code below, I encountered an issue. In IE and Chrome, when hovering over the "CODE" section, the div correctly appears at position 100 x 100. However, in Firefox, the div fails to move to the specified position. What changes should b ...

When attempting to create a BMI calculator in Flutter, the challenge arises when trying to define BoxConstraints within the constraints parameter, resulting in the error message "The named parameter 'constraints' isn't defined."

class RoundIconButton extends StatelessWidget { const RoundIconButton(this.icon, this.onPress); final Function onPress; final IconData icon; @override Widget build(BuildContext context) { return MaterialButton( child: Icon(icon), elev ...

Challenges with utilizing Java reflection to access Google Play services classes

My current challenge involves trying to access Google Play Services classes using the java reflection approach. Here is my code snippet: Class<?> adIdClientClass; try { adIdClientClass = Class.forName("com.google.android.gms.ads.identifi ...

Display class name in React only when the variable is set to true

import React from 'react'; import logo from './logo.svg'; import './App.css'; function App() { return ( <div className="App"> <h1 className={ isTrue ? 'primary' : ''}>{ fa ...

What is the best way to programmatically click on each list item without triggering their normal behavior and silently loading their content instead?

I am looking to programmatically click on a series of unordered list items without showing the results of the clicks. The goal is to preload dynamic content such as images and text that would normally be loaded and displayed upon clicking on the list items ...

An issue occurred while running the "gulp test" command due to a problem with the 'gulp-tslint-log'

Having issues running gulp on a JHipster generated project. I've already installed all node_modules using npm install and here are my package.json and gulpfile.js: { "name": "myapp", "version": "0.0.0", "description": "Description for myapp", ...

Leveraging Iron Router for implementing query variable settings

Utilizing Iron Router, I aim to call a page and filter the results based on the route. In this scenario, the application facilitates the creation of items. Each item contains an array that can encompass zero to multiple tags: Item: { _id: <assigned b ...

The PHP server is having trouble accepting a JavaScript object sent via AJAX

Hey there, I'm currently facing an issue with sending fields from a form saved in a JavaScript object to a PHP server. I have set up the AJAX communication, but when I try to access the object in PHP, I notice that the length is showing as 0 during de ...

What is the best way to incorporate a function that works seamlessly with elements?

For the elements with corresponding 'li' that has a selected class, I need to set the selected property only for those specific 'option' elements. The value is determined by the data-input-value attribute in the 'li' and the v ...