androidgoogle-blogger-api

Blogger API Retrieve specific post issue loading content in WebView


I was using Blogger API of Retrieving posts from a blog, from the response of this API call there is a key named content that contains HTML code of the post and I'm trying to load that HTML in a WebView, but the problem is that it is not loading all content in WebView. Here is the code to load HTML in WebView.

webView.loadData(content, "text/html", "UTF-8");

In the above code snippet, the content is a String type variable that contains complete web page HTML code.

Response of the API:

{
      "kind": "blogger#post",
      "id": "589230665373284492",
      "blog": {
        "id": "3332972326669427275"
      },
      "published": "2020-10-17T19:20:00-07:00",
      "updated": "2020-10-17T23:54:37-07:00",
      "url": "http://devofandroid.blogspot.com/2020/10/picture-in-picture-android-studio-kotlin.html",
      "selfLink": "https://www.googleapis.com/blogger/v3/blogs/3332972326669427275/posts/589230665373284492",
      "title": "Picture In Picture | Android Studio | Kotlin",
2020-10-25 08:09:45.938 26635-26635/com.blogspot.atifsoftwares.blogger D/POST_DETAILS_TAG:   "content": "\u003cp\u003e\u003c/p\u003e\u003ch1 style=\"text-align: left;\"\u003eHow to add Picture In Picture Mode in the android app?\u003c/h1\u003e\u003cp style=\"text-align: justify;\"\u003eThe Android 8.0 (API level 26) allows activities to launch in the picture-in-picture (PIP) mode. PIP is a special type of multi-window mode mostly used for video playback. It lets the user watch a video in a small window pinned to a corner of the screen while navigating between apps or browsing content on the main screen. The PIP window appears in the top layer of the screen in a corner chosen by the system.\u003c/p\u003e\u003cp\u003e\u003c/p\u003e\u003cp\u003e\u003ca href=\"https://devofandroid.blogspot.com/2020/10/picture-in-picture-android-studio-java.html\"\u003e>>Check For Java\u003c/a\u003e\u003c/p\u003e\u003ch4 style=\"text-align: left;\"\u003eVideo:\u003c/h4\u003e\u003cdiv\u003e\n\u003ciframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/mnaePNH9V3k\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen\u003e\u003c/iframe\u003e\n\u003c/div\u003e\u003ch4 style=\"background-color: white; color: #4d4d4d; font-family: Roboto, sans-serif; font-size: 15px; text-align: justify;\"\u003eStep 1: \u003ca href=\"http://devofandroid.blogspot.com/2018/03/first-app-in-android-studio-kotlin-use.html\" style=\"background: transparent; color: #d80b0b; outline: 0px; text-decoration-line: none;\"\u003eCreate a new project\u003c/a\u003e\u003cspan face=\"roboto, sans-serif\"\u003e \u003c/span\u003e\u003cspan face=\"roboto, sans-serif\"\u003eor\u003c/span\u003e\u003cspan face=\"roboto, sans-serif\"\u003e \u003c/span\u003e\u003ca href=\"http://devofandroid.blogspot.com/2018/03/how-to-open-existing-project-in-android.html\" style=\"background: transparent; color: #d80b0b; text-decoration-line: none;\"\u003eopen an existing project\u003c/a\u003e\u003c/h4\u003e\u003ch4 style=\"background-color: white; color: #4d4d4d; font-family: Roboto, sans-serif; font-size: 15px; text-align: justify;\"\u003eStep 2: Create another activity named PIPActivity\u003c/h4\u003e\u003ch4 style=\"background-color: white; color: #4d4d4d; font-family: Roboto, sans-serif; font-size: 15px; text-align: justify;\"\u003e\u003cspan face=\"roboto, sans-serif\" style=\"background-color: transparent; color: #111111; text-align: left;\"\u003e\u003cspan style=\"font-size: 14px; white-space: pre-wrap;\"\u003eStep 3: Add the following properties to the \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"background-color: transparent; text-align: left;\"\u003ePIPActivity in AndroidManifest\u003c/span\u003e\u003c/h4\u003e\u003cdiv\u003e\u003cspan style=\"background-color: transparent; text-align: left;\"\u003e\n  \u003cdiv style=\"background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;\"\u003e\u003cpre style=\"line-height: 125%; margin: 0px;\"\u003e\u003cspan style=\"color: #007700;\"\u003e<activity\u003c/span\u003e \u003cspan style=\"color: #0000cc;\"\u003eandroid:name=\u003c/span\u003e\u003cspan style=\"background-color: #fff0f0;\"\u003e\".PIPActivity\"\u003c/span\u003e\n            \u003cspan style=\"color: #0000cc;\"\u003eandroid:configChanges=\u003c/span\u003e\u003cspan style=\"background-color: #fff0f0;\"\u003e\"screenSize|smallestScreenSize|screenLayout|orientation\"\u003c/span\u003e\n            \u003cspan style=\"color: #0000cc;\"\u003eandroid:launchMode=\u003c/span\u003e\u003cspan style=\"background-color: #fff0f0;\"\u003e\"singleTask\"\u003c/span\u003e\n            \u003cspan style=\"color: #0000cc;\"\u003eandroid:resizeableActivity=\u003c/span\u003e\u003cspan style=\"background-color: #fff0f0;\"\u003e\"true\"\u003c/span\u003e\n            \u003cspan style=\"color: #0000cc;\"\u003eandroid:supportsPictureInPicture=\u003c/span\u003e
2020-10-25 08:09:45.938 26635-26635/com.blogspot.atifsoftwares.blogger D/POST_DETAILS_TAG:   "author": {
        "id": "07474932866787621864",
        "displayName": "Atif Pervaiz",
        "url": "https://www.blogger.com/profile/07474932866787621864",
        "image": {
          "url": "//2.bp.blogspot.com/-9c4mLBCE9Q0/X4uslXybcjI/AAAAAAAAKeg/mMtVYJGLDTM2dHrOj5ULHRa_BvSQ1z7OgCK4BGAYYCw/s35/B612_20200913_170020_321.jpg"
        }
      },
      "replies": {
        "totalItems": "0",
        "selfLink": "https://www.googleapis.com/blogger/v3/blogs/3332972326669427275/posts/589230665373284492/comments"
      },
      "labels": [
        "android",
        "android 8",
        "android O",
        "android studio",
        "Kotlin",
        "picture in picture",
        "picture in picture mode",
        "pip",
        "pip mode",
        "tutorial"
      ],
      "etag": "\"dGltZXN0YW1wOiAxNjAzMDA0MDc3NzQxCm9mZnNldDogLTI1MjAwMDAwCg\""
    }

Here is a screenshot, that shows there is no more data after Youtube Video.


Solution

  • You can try using webView.loadDataWithBaseURL(null, content, MIME, ENCODING, null); You can refer docs here