<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vishnutejareddy on Medium]]></title>
        <description><![CDATA[Stories by Vishnutejareddy on Medium]]></description>
        <link>https://medium.com/@vishnutejareddy10?source=rss-21c4e2251753------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*00wLAKJv-VCI84ZW</url>
            <title>Stories by Vishnutejareddy on Medium</title>
            <link>https://medium.com/@vishnutejareddy10?source=rss-21c4e2251753------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:48:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vishnutejareddy10/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[CI-CD IN ANDROID: Upload your app to Play Console on Pushing to Github]]></title>
            <link>https://medium.com/@vishnutejareddy10/ci-cd-in-android-upload-your-app-to-play-console-on-pushing-to-github-d33e37ec24c0?source=rss-21c4e2251753------2</link>
            <guid isPermaLink="false">https://medium.com/p/d33e37ec24c0</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Vishnutejareddy]]></dc:creator>
            <pubDate>Mon, 09 Jun 2025 17:00:55 GMT</pubDate>
            <atom:updated>2025-06-09T17:04:35.869Z</atom:updated>
            <content:encoded><![CDATA[<p>Tired of the manual, error-prone process of building, signing, and uploading your Android App Bundles (AABs) to the Google Play Console? It’s time to automate! This guide will walk you through creating a powerful and efficient CI/CD (Continuous Integration/Continuous Deployment) pipeline using GitHub Actions.</p><p>Once set up, every push to your main branch will automatically build a signed AAB and upload it directly to the Google Play Console, ready for testing or release. Let’s get started! 🚀</p><h3><strong>Part 1: Google Play Console &amp; Service Account Setup</strong></h3><p>First, we need to create a secure bridge between GitHub Actions and the Google Play Console. This is done using a <strong>Service Account</strong>.</p><p><strong>Create a Google Cloud Service Account:</strong></p><ol><li>Navigate to the Google Cloud Console.</li><li>Select the Google Cloud project linked to your Play Console account, or create a new one.</li><li>Go to <strong>IAM &amp; Admin</strong> -&gt; <strong>Service Accounts</strong>.</li><li>Click <strong>CREATE SERVICE ACCOUNT</strong>.</li><li>Give it a name (e.g., “play-console-uploader”) and a description. Click <strong>CREATE AND CONTINUE</strong>.</li><li>For the role, select <strong>Service Account User</strong>. Click <strong>CONTINUE</strong>.</li><li>Skip step 3 (“Grant users access to this service account”) and click <strong>DONE</strong>.</li><li>Find your new service account in the list. Note down its email address; you’ll need it soon.</li></ol><p><strong>2. Generate a JSON Key</strong></p><p>This key is a password for your service account. Keep it secure!</p><ol><li>Click the three dots (Actions) next to your service account and select <strong>Manage keys</strong>.</li><li>Click <strong>ADD KEY</strong> -&gt; <strong>Create new key</strong>.</li><li>Choose <strong>JSON</strong> and click <strong>CREATE</strong>. A JSON file will download to your computer.</li></ol><p><strong>3. Grant Permissions in Play Console</strong></p><p>Now, invite the service account to be a user in your Play Console.</p><ol><li>Open your <a href="https://play.google.com/console/?authuser=4">Google Play Console</a>.</li><li>Go to <strong>Users and permissions</strong> -&gt; <strong>Invite new users</strong>.</li><li>Paste the service account’s email address into the email field.</li><li>Under <strong>App permissions</strong>, select the specific app you want to automate.</li><li>Under <strong>Account permissions</strong>, I prefer to grant Admin</li></ol><p>[ else, grant it at least the following permissions:</p><ul><li><strong>View app information and download bulk reports (read-only)</strong></li><li><strong>Manage testing tracks and edit tester lists</strong></li><li>(If needed for production) <strong>Manage production releases, app signing, and Play Games Services projects ]</strong></li></ul><p>6. Click <strong>Invite user</strong>. Your service account can now access the Play Console API.</p><h3><strong>Part 2: Configuring App Signing</strong></h3><p>Google Play App Signing is the recommended standard. It means Google manages the final key that signs your app for users, and you sign your AAB with a secure <strong>Upload Key</strong>.</p><p>We need a keystore for this.</p><p>Go to Build -&gt;Generate Signed App Bundle / Apk-&gt;select ‘Android App Bundle’-&gt;under Keystore Path choose CreateNew-&gt;fill the fields</p><p>Note:</p><p>1. It is better if you keep the keystore and key passwords as same for remembering else you might end up forgetting them.</p><p>2. Also remember the alias name clearly, it is useful in later stages of the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OecT35WtKXFp8qrVNcUq2w.png" /></figure><h3><strong>Part 3: Enable google play developer Api in cloud console</strong></h3><p>Goto Console.cloud.google.com -&gt; Select your project</p><p>In the left pane : <strong>Apis &amp;Services</strong></p><p>Search for <strong>Google Play Android</strong> : Enable Google Play Android Developer API.</p><h3><strong>Part 4: Setting Up GitHub Secrets</strong></h3><p>Never expose your keys or passwords in your code. Use GitHub’s encrypted secrets.</p><ol><li>In your GitHub repository, go to <strong>Settings</strong> -&gt; <strong>Secrets and variables</strong> -&gt; <strong>Actions</strong>.</li><li>Click <strong>New repository secret</strong> for each of the following:</li></ol><ul><li><strong>SERVICE_ACCOUNT_JSON_PLAIN_TEXT</strong>: Open the JSON file you downloaded earlier. Copy its <strong>entire content</strong> and paste it here.</li><li><strong>UPLOAD_KEYSTORE_BASE64</strong>: This is your .jks file, but encoded. Go to <a href="https://base64.guru/converter/encode/file">https://base64.guru/converter/encode/file</a> and convert your jks to base64 and copy the text and paste it in this variable.</li><li><strong>UPLOAD_KEYSTORE_PASSWORD</strong>: The password for your keystore file.</li><li><strong>UPLOAD_KEY_ALIAS</strong>: The alias for your key.</li><li><strong>UPLOAD_KEY_PASSWORD</strong>: The password for the key alias itself.</li></ul><h3>Part 5: Configuring Your Android Project</h3><p>Now, let’s tell Gradle how to sign your app.</p><h3>For build.gradle.kts (Kotlin DSL):</h3><p>Add this to your app/build.gradle.kts file inside the android block.</p><pre>signingConfigs {<br>    create(&quot;release&quot;) {<br>        storeFile = file(System.getenv(&quot;UPLOAD_KEYSTORE_FILE&quot;) ?: &quot;your_upload_keystore.jks&quot;)<br>        storePassword = System.getenv(&quot;UPLOAD_KEYSTORE_PASSWORD&quot;)<br>        keyAlias = System.getenv(&quot;UPLOAD_KEY_ALIAS&quot;)<br>        keyPassword = System.getenv(&quot;UPLOAD_KEY_PASSWORD&quot;)<br>    }<br>}<br><br>buildTypes {<br>    getByName(&quot;release&quot;) {<br>        isMinifyEnabled = true<br>        proguardFiles(getDefaultProguardFile(&quot;proguard-android-optimize.txt&quot;), &quot;proguard-rules.pro&quot;)<br>        signingConfig = signingConfigs.getByName(&quot;release&quot;)<br>    }<br>}</pre><h3>For build.gradle (Groovy DSL):</h3><p>Add this to your app/build.gradle file inside the android block.</p><p>Groovy</p><pre>signingConfigs {<br>    release {<br>        storeFile file(System.getenv(&quot;UPLOAD_KEYSTORE_FILE&quot;) ?: &quot;your_upload_keystore.jks&quot;)<br>        storePassword System.getenv(&quot;UPLOAD_KEYSTORE_PASSWORD&quot;)<br>        keyAlias System.getenv(&quot;UPLOAD_KEY_ALIAS&quot;)<br>        keyPassword System.getenv(&quot;UPLOAD_KEY_PASSWORD&quot;)<br>    }<br>}<br><br>buildTypes {<br>    release {<br>        minifyEnabled true<br>        proguardFiles getDefaultProguardFile(&#39;proguard-android-optimize.txt&#39;), &#39;proguard-rules.pro&#39;<br>        signingConfig signingConfigs.release<br>    }<br>}</pre><p>This setup reads the signing credentials from environment variables, which we will set in our GitHub Actions workflow.</p><h3><strong>Part 6: The GitHub Actions Workflow</strong></h3><p>This is the final piece! Create a file at .github/workflows/android_release.yml in your project and paste the following content:</p><p>YAML file:</p><pre>name: Android CI/CD - Release to Play Store<br><br># Controls when the workflow will run<br>on:<br>  # Triggers the workflow on push or pull request events but only for the &quot;master&quot; branch<br>  pull_request:<br>    branches: [ master ]<br>  push:<br>    branches: [ master ]<br><br>jobs:<br>  build-and-release:<br>    runs-on: ubuntu-latest<br>    env: # Define environment variables that Gradle will use<br>      UPLOAD_KEYSTORE_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_PASSWORD }}<br>      UPLOAD_KEY_ALIAS: ${{ secrets.UPLOAD_KEY_ALIAS }}<br>      UPLOAD_KEY_PASSWORD: ${{ secrets.UPLOAD_KEY_PASSWORD }}<br>      # UPLOAD_KEYSTORE_FILE will be set dynamically in a step below<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4<br><br>      - name: Set up JDK 17<br>        uses: actions/setup-java@v4<br>        with:<br>          java-version: &#39;17&#39; # Or your project&#39;s JDK version<br>          distribution: &#39;temurin&#39;<br>          cache: gradle<br>        # This step creates the keystore file from the Base64 secret<br>        # and sets the UPLOAD_KEYSTORE_FILE environment variable for subsequent steps.<br>        #        run: echo &quot;${{ secrets.UPLOAD_KEYSTORE_BASE64 }}&quot; | base64 -d &gt; keystore.jks<br><br>      - name: Decode Keystore and Set Path<br>        run: |<br>          echo &quot;${{ secrets.UPLOAD_KEYSTORE_BASE64 }}&quot; | base64 --decode &gt; release.jks<br>          echo &quot;UPLOAD_KEYSTORE_FILE=$(pwd)/release.jks&quot; &gt;&gt; $GITHUB_ENV<br><br><br>      - name: Grant execute permission for gradlew<br>        run: chmod +x ./gradlew<br><br>      - name: Build aab<br>        run: ./gradlew bundleRelease # Or your specific bundle task<br><br><br>      - name: Upload AAB to Google Play<br>        uses: r0adkll/upload-google-play@v1.1.3 # Check for the latest version<br>        with:<br>          serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON_PLAIN_TEXT }}<br>          packageName: com.andrayudu.cicdarticle # Replace with your app&#39;s package name<br>          releaseFiles: app/build/outputs/bundle/release/*.aab # Path to your AAB<br>          track: internal # Or alpha, beta, production, internalappsharing<br>          status: draft # &lt;&lt;&lt; --- CHANGE THIS TO &#39;draft&#39;<br>          # userFraction: 0.5 # For staged rollouts (e.g., 50%) - optional<br>          # whatsNewDirectory: whatsnew/ # Path to release notes (optional)<br>          # mappingFile: app/build/outputs/mapping/release/mapping.txt # Optional mapping file<br>          # debugSymbols: app/build/outputs/native-debug-symbols/release/*.zip # Optional native debug symbols<br>          # status: completed # Or &#39;draft&#39;, &#39;inProgress&#39;<br><br></pre><p><strong>What this workflow does:</strong></p><p>1. <strong>Triggers</strong> on every push to the main branch.</p><p>2. <strong>Checks out</strong> your project code.</p><p>3. <strong>Sets up</strong> the Java environment.</p><p>4. <strong>Decodes</strong> your secure UPLOAD_KEYSTORE_BASE64 secret into a release.jks file that Gradle can use.</p><p>5. <strong>Builds</strong> your app, creating a release AAB signed with your upload key.</p><p>6. <strong>Uploads</strong> the signed AAB to the internal track of the Play Console as a draft release.</p><p>Before pushing the code and running the cicd pipeline,</p><p>You should upload the signed aab to play console using internal testing track.</p><p>This saves the package name to your project in play console.</p><p>Goto build -&gt; Generate signed app bundle or apk</p><p>Go to play console -&gt;Test and release -&gt; testing-&gt; Internal testing -&gt; create new release</p><p>Upload the file and click next,Now after completing above step,</p><p>Push the code and in github-&gt; actions you can see the flow running</p><p>Once the flow completes,</p><p>You can see the uploaded aab in playconsole-&gt; test and release &gt; latest releases</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LVN-l-OM_Ywx7LYsM36Lsg.jpeg" /></figure><p>Click on the corner -&gt;,</p><p>And click next ,Click save and publish</p><p>Now your app is live in internal testing …</p><p>Note : for deploying the app to production change track to ‘production’ in yml file.</p><p><strong>Conclusion</strong></p><p>That’s it! Now, push a change to your main branch and watch the magic happen in the “Actions” tab of your GitHub repository. Your AAB will appear as a draft release in the Play Console, ready for your final review.</p><p>You’ve successfully eliminated a tedious manual process, reduced the chance of human error, and created a robust CI/CD pipeline for your Android app. Congratulations! 🎉</p><p>You can find the github repo link here : <a href="https://github.com/VISHNUONE8/CICD-Article/tree/master">https://github.com/VISHNUONE8/CICD-Article/tree/master</a></p><p>Navigate to Actions in Github and you can see the workflow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d33e37ec24c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Renaming package in Android]]></title>
            <link>https://medium.com/@vishnutejareddy10/renaming-package-in-android-4534f2cc9598?source=rss-21c4e2251753------2</link>
            <guid isPermaLink="false">https://medium.com/p/4534f2cc9598</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Vishnutejareddy]]></dc:creator>
            <pubDate>Tue, 23 Jul 2024 11:16:41 GMT</pubDate>
            <atom:updated>2024-07-23T11:16:41.062Z</atom:updated>
            <content:encoded><![CDATA[<p>I) Generally, package contains 3 elements</p><p>Ex: com.android.hello</p><p>1st part <strong>com</strong></p><p>2nd part <strong>android</strong></p><p>3rd part <strong>hello</strong></p><p>Go to the directory where you want to change the package name.</p><p>II) Say, if you want to change the part <strong>hello </strong>to <strong>hi</strong>.</p><p>III) Go to the directory ‘hi’ <strong>Right click </strong>-&gt;<strong>Refactor </strong>-&gt;<strong>Rename</strong>. Then, it will pop a dialog asking whether to rename in All Directories.</p><p>Click ‘<strong>All Directories</strong>’, type in the new name ‘hi’ and then click <strong>Refactor</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*xF3e9qOPdUWB3gARn8WSwg.png" /><figcaption>Renaming package using Refactor</figcaption></figure><p>IV) After renaming you have to verify whether the package name is changed in</p><p>i)AndroidManifest.xml (name attribute in every activity)</p><p>ii)build.gradle(app) (manually change under attributes namespace,applicationId)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*z3OVBb7-CK0suFSpTRKOxw.png" /><figcaption>build.gradle file</figcaption></figure><p>V) Now go to Build on the top and click Clean Project and again rebuild the project. Still if you are facing any issues then click <strong>File </strong>-&gt;<strong> Invalidate Caches</strong> -&gt;select all -&gt; click I<strong>nvalidate and Restart</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*NxfUCkq1l84YMiC3XGregg.png" /></figure><p>VI) In this way, we can successfully rename package name in android.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4534f2cc9598" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Animated Splash Screen (with free Resources) in Android]]></title>
            <link>https://medium.com/@vishnutejareddy10/animated-splash-screen-with-free-resources-in-android-bbaab13229ea?source=rss-21c4e2251753------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbaab13229ea</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[splash-screen]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Vishnutejareddy]]></dc:creator>
            <pubDate>Mon, 03 Jun 2024 06:18:22 GMT</pubDate>
            <atom:updated>2024-09-04T05:42:16.053Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, you will learn how to create an animated splash screen for your android app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gR4uJXsIOvomNQPK_2ux5Q.jpeg" /><figcaption>Animated splash screen</figcaption></figure><ol><li>Convert the image of your choice into an svg file using adobe’s image to svg converter.</li></ol><p>Here’s the link : <a href="https://new.express.adobe.com/tools/convert-to-svg?%24web_only=true&amp;_branch_match_id=1134477861951282960&amp;_branch_referrer=H4sIAAAAAAAAA8soKSkottLXT0zJT0otLkgsyi7ILy7RLU9N0kssKNDLyczL1k%2FVj6qIyM6y9PAw9UgCACXYts0xAAAA">Adobe Express</a></p><p>2. Later, Open Figma in web browser, create a new project, create a Frame of size 288 X 288, circle of size 192 in diameter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H9mXNDRNj3sZT20DFa2sHQ.png" /><figcaption>Splash icon in Figma with dimensions</figcaption></figure><p>2.1 Copy paste the converted svg of your image in step 1 .</p><p>2.2 Resize the converted svg to fit into the circle.</p><p>2.3 Delete the circle, move svg into rectangle</p><p>2.4 Finally, export it as svg.</p><p>We are resizing because these are the preferred splash screen dimensions by google.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*S1ik-YXEAlHdLiYgg-dpIQ.png" /><figcaption>reference: google splash screen docs</figcaption></figure><p>3. The saved svg from figma should be imported into shape shifter and add the animations like scalex,scaley, rotation and add their duration ,start end points respectively.</p><p>Here is the link for shapeshifter: <a href="https://shapeshifter.design/">Shape Shifter</a></p><p>3.1 for rotating the image 360 degrees ; start = 0, end = 360</p><p>3.2 for scaling x from 0 to 85% ; start = 0, end = 0.85</p><p>3.3 After animations are added,preview the animation using play button. Export the file as Animated Vector Drawable.</p><p>4. The exported AVD file will be in xml format.</p><p>4.1 Copy the file to the drawable folder.</p><p>4.2 Use it in windowSplashScreenAnimatedIcon.</p><pre>&lt;item name=&quot;android:windowSplashScreenAnimatedIcon&quot;&gt;@drawable/avd_andhradairy&lt;/item&gt;</pre><p>Here is the full splash theme code:</p><pre>&lt;style name=&quot;Theme.SplashScreen.AndhraDairySplash&quot; parent=&quot;Theme.SplashScreen&quot;&gt;<br>    &lt;item name=&quot;android:windowSplashScreenBackground&quot;&gt;#FFFFFF&lt;/item&gt;<br>    &lt;item name=&quot;android:windowSplashScreenAnimatedIcon&quot;&gt;@drawable/avd_andhradairy&lt;/item&gt;<br>    &lt;item name=&quot;android:windowSplashScreenAnimationDuration&quot;&gt;1000&lt;/item&gt;<br><br>&lt;/style&gt;</pre><p>4.1 You can change the duration of splash screen from 1000ms to 2000ms if you want to display it for longer durations.</p><p>You can see the final result by visiting the below link:</p><p><a href="https://drive.google.com/file/d/1NOaQrrIqVo8mdj-KSOdrZP0cehq7JVAr/view?usp=sharing">Screenrecorder-2024-06-03-11-43-54-556[1].mp4</a></p><p>Here is the full implementation/ source code of the App:</p><p><a href="https://github.com/VISHNUONE8/AnimatedSplashScreen">VISHNUONE8/AnimatedSplashScreen (github.com)</a></p><p>If you want a video demonstration of the following article, visit stevdza-san:</p><p><a href="https://www.youtube.com/watch?v=Oy0oXwv3kSc">The Ultimate Guide to Android Splash Screen Animations — Splash API (youtube.com)</a></p><p>References:</p><p><a href="https://developer.android.com/develop/ui/views/launch/splash-screen#kts">Splash screens | Views | Android Developers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbaab13229ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open pdf using WebView- Jetpack compose]]></title>
            <link>https://medium.com/@vishnutejareddy10/open-pdf-using-webview-jetpack-compose-b1e12ed45120?source=rss-21c4e2251753------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1e12ed45120</guid>
            <category><![CDATA[jetpack]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Vishnutejareddy]]></dc:creator>
            <pubDate>Tue, 28 May 2024 11:14:58 GMT</pubDate>
            <atom:updated>2024-05-31T12:08:06.642Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Use cases &amp; Advantages:</strong></p><ol><li>For loading policy docs like privacy policy, shipping, return and refund policy or any other pdfs.</li><li>For displaying a bit of navigation information that keeps updating every now and then.</li><li>For Quick view of pdfs without moving the user out of app.</li></ol><p>Nowadays every app has to have some privacy policy in order to be listed on Play store/Appstore. Also, for shopping/e-commerce/food delivery apps, inside the application, policies like shipping, return &amp; refund should be shown.</p><p>So, without navigating the user out of our app, we can use WebView in jetpack compose to display the pdf format docs that are uploaded on to Google drive.</p><p>Also, we can open pdfs that aren’t in google drive using the direct links in Android WebView.</p><p><strong>To load pdf docs from google drive link:</strong></p><ol><li>Enable sharing and access to everyone with the link.</li><li>Add the accompanist WebView library dependency into app level build.gradle file</li></ol><pre>implementation &quot;com.google.accompanist:accompanist-webview:0.28.0&quot;</pre><p>for version compatibility please check the link:</p><p><a href="https://github.com/google/accompanist">google/accompanist: A collection of extension libraries for Jetpack Compose (github.com)</a></p><p>3. Copy the sharing link and store it in a variable using remember</p><pre>var url by remember { mutableStateOf(&quot;https://drive.google.com/file/d/168HtsWKFXA5-uqrG21QvQNfEJPvyhORJ/view?usp=sharing&quot;) }</pre><p>Here is the full implementation :</p><pre>//this function  is only for loading animation,remove it if you don&#39;t need<br>@Composable<br>fun CircularProgressBar(viewModel: MainViewModel = viewModel(), modifier: Modifier ){<br> val isPdfLoading = viewModel.isPdfLoading.value<br> if (isPdfLoading){<br> CircularProgressIndicator(<br> modifier = modifier<br> .width(100.dp)<br> .height(100.dp),<br> color = ProgressIndicatorDefaults.circularColor,<br> strokeWidth = ProgressIndicatorDefaults.CircularStrokeWidth<br> )<br> }<br><br>}<br>//this is the main composable function<br>@Composable<br>fun PdfWebview(viewModel: MainViewModel = viewModel()) {<br><br> var url by remember { mutableStateOf(&quot;https://drive.google.com/file/d/168HtsWKFXA5-uqrG21QvQNfEJPvyhORJ/view?usp=sharing&quot;) }<br> val state = rememberWebViewState(url = url)<br> val navigator = rememberWebViewNavigator()<br> var textFieldValue by remember(state.content.getCurrentUrl()) {<br> mutableStateOf(state.content.getCurrentUrl() ?: &quot;&quot;)<br> }<br> // A custom WebViewClient and WebChromeClient can be provided via subclassing<br> val webClient = remember {<br> object : AccompanistWebViewClient() {<br><br> override fun onPageFinished(view: WebView?, url: String?) {<br> super.onPageFinished(view, url)<br> Log.d(&quot;Accompanist WebView&quot;, &quot;Page finished loading for $url&quot;)<br> viewModel.isPdfLoading.value = false<br> }<br><br> override fun onPageStarted(<br> view: WebView?,<br> url: String?,<br> favicon: Bitmap?<br> ) {<br> super.onPageStarted(view, url, favicon)<br> Log.d(&quot;Accompanist WebView&quot;, &quot;Page started loading for $url&quot;)<br> }<br> }<br> }<br><br> Box(modifier = Modifier.fillMaxSize(),<br> contentAlignment = Alignment.Center){<br><br> Column {<br> Row(modifier = Modifier.padding(all = 12.dp)) {<br> BasicTextField(<br> modifier = Modifier.weight(9f),<br> value = textFieldValue,<br> onValueChange = { textFieldValue = it },<br> maxLines = 1<br> )<br> if (!state.errorsForCurrentRequest.isEmpty()) {<br> Icon(<br> modifier = Modifier<br> .weight(1f),<br> imageVector = Icons.Default.Warning,<br> contentDescription = &quot;Error&quot;,<br> tint = Color.Red<br> )<br> }<br> }<br><br> val loadingState = state.loadingState<br> if (loadingState is LoadingState.Loading) {<br> LinearProgressIndicator(<br> progress = loadingState.progress,<br> modifier = Modifier.fillMaxWidth()<br> )<br><br> }<br><br> WebView(state = state,<br> modifier = Modifier.weight(1f),<br> navigator = navigator,<br> onCreated = {webView -&gt;<br> webView.settings.javaScriptEnabled = true<br> },<br> client = webClient<br> )<br> }<br><br> CircularProgressBar(modifier = Modifier<br> .width(100.dp)<br> .height(100.dp))<br><br> }<br><br>}</pre><p>You can refer my GitHub for fullproject implementation and dependency related details:</p><p><a href="https://github.com/VISHNUONE8/PdfWebviewJetpackCompose">VISHNUONE8/PdfWebviewJetpackCompose (github.com)</a></p><p>References:</p><p><a href="https://youtu.be/JOgkUOOoWcs?si=lQWQNICVVjzsGVKu">https://youtu.be/JOgkUOOoWcs?si=lQWQNICVVjzsGVKu</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1e12ed45120" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Learnings & Tips — rememberSaveable, ksp plugin, callbackFlow]]></title>
            <link>https://medium.com/@vishnutejareddy10/android-learnings-tips-remembersaveable-ksp-plugin-callbackflow-d18488b1fbf6?source=rss-21c4e2251753------2</link>
            <guid isPermaLink="false">https://medium.com/p/d18488b1fbf6</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Vishnutejareddy]]></dc:creator>
            <pubDate>Mon, 20 May 2024 14:16:00 GMT</pubDate>
            <atom:updated>2024-05-20T14:16:00.579Z</atom:updated>
            <content:encoded><![CDATA[<h3><a href="https://medium.com/@vishnutejareddy10/android-learnings-tips-displayed-inline-function-sealed-class-052f60ec5f47?source=your_stories_page-------------------------------------">Android Learnings &amp; Tips — rememberSaveable, ksp plugin, callbackFlow</a></h3><p><strong>rememberSaveable</strong>: rememberSaveable is a function used for the persistence of state in Jetpack compose even during configuration changes.<br>i.e. it remembers the state even after screen rotation, keyboard change, language change etc.</p><p>The rememberSaveable implements the Bundle savedInstanceState to retain the state across configuration changes.</p><p>(state in jetpack compose refers to data value that may change during the lifetime of a composable function and needs to be preserved during recompositions).</p><h4>usage:</h4><pre>var isVsible by rememberSaveable{<br> mutableStateOf(false)<br>}</pre><p>in above example, the value of isVisible will be maintained even when device config changes occur.</p><p>Though rememberSaveable maintains the state even during config changes, it is only prefered with primitive datatypes.<br>Hence for complex data structures, it is better to declare state variables in viewmodel.<br>for clear cut details on rememberSaveable:<br><a href="https://amitshekhar.me/blog/remember-vs-remembersaveable">https://amitshekhar.me/blog/remember-vs-remembersaveable</a><br><a href="https://medium.com/@seungbae2/jetpack-compose-remembersaveable-simplifying-state-persistence-for-seamless-user-experience-b2f721692228">https://medium.com/@seungbae2/jetpack-compose-remembersaveable-simplifying-state-persistence-for-seamless-user-experience-b2f721692228</a></p><p><strong>KSP plugin</strong>:</p><p>Kotlin symbol processing(ksp) is an API that you can use to develop lightweight compiler plugins.</p><p>i)compared to kapt,annotation processors that use ksp can run upto two times faster i.e. build performance is better over kapt.</p><p>ii)ksp makes creating lightweight compiler plugins easier.</p><p>iii)ksp is a more idiomatic API</p><p>idiom: kill two birds with 1 stone 😜</p><p>meaning: get two things done with a single action.</p><p>iv)It has the ability to understand kotlin-only symbols.</p><p>for further info on ksp plugin refer:</p><p><a href="https://kotlinlang.org/docs/ksp-overview.html">Kotlin Symbol Processing API | Kotlin Documentation (kotlinlang.org)</a></p><p><strong>callbackFlow:</strong></p><p>just like we observe changes in the data and update the UI using live data, callbackFlow does similar job by calling back a code (like updation of UI) when updates to the data happen.</p><pre>fun signInWithCredential(otp: String): Flow&lt;ResultState&lt;String&gt;&gt;  = callbackFlow{<br>    trySend(ResultState.Loading)<br>    val credential = PhoneAuthProvider.getCredential(omVerificationCode,otp)<br>    authdb.signInWithCredential(credential)<br>        .addOnCompleteListener {<br>            if(it.isSuccessful)<br>                trySend(ResultState.Success(&quot;otp verified&quot;))<br>        }.addOnFailureListener {<br>            trySend(ResultState.Failure(it))<br>        }<br>    awaitClose {<br>        close()<br>    }<br>}</pre><p>In the above example fun signInWithCredential(otp:String) is used to login a user with mobile number , otp using firebase authentication.</p><p>If the authentication is successful, the callback sends success result else it will send failure result/response .</p><p>The result will be observed i.e collected in viewmodel for any updates :</p><pre>loadUserDataUsingFlow().collect{result-&gt;<br>    _dataFlow.value = result<br>}</pre><p>so we will collect the result and run the code inside it or simply we can update the UI as shown above.</p><p>for further details and examples on callbackFlow visit:</p><p><a href="https://amitshekhar.me/blog/callback-to-flow-api-in-kotlin">callbackFlow — Callback to Flow API in Kotlin (amitshekhar.me)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d18488b1fbf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Learnings & Tips - Displayed,Inline function,Sealed Class]]></title>
            <link>https://medium.com/@vishnutejareddy10/android-learnings-tips-displayed-inline-function-sealed-class-052f60ec5f47?source=rss-21c4e2251753------2</link>
            <guid isPermaLink="false">https://medium.com/p/052f60ec5f47</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Vishnutejareddy]]></dc:creator>
            <pubDate>Mon, 13 May 2024 03:46:29 GMT</pubDate>
            <atom:updated>2024-05-13T03:46:29.621Z</atom:updated>
            <content:encoded><![CDATA[<h3>1) Displayed : To know which Activity is currently running on emulator/device, type “Displayed” as a logcat filter.</h3><ul><li>The system_server process will log the currently shown activity in logcat.</li></ul><p>Use : It will be useful in large projects to know,the name of the displayed activity on screen.Using the activity name, we can explore the source code of that project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0_rNoh7AMYDQRwR8nLs0Ag.png" /></figure><p>In above figure, On opening DuckDuckGo App, the launched activity is “Browser Activity” can be seen using “Displayed” logcat filter.</p><p>2.<strong> Inline Functions(in kotlin) : Inline function as its name suggests, will insert the complete body of the function (i.e code) at the line it is called.</strong></p><pre>fun example(){<br>print(&quot;example start&quot;)<br>sample()<br>print(&quot;example end&quot;)<br>}<br>inline fun sample(){<br>print(&quot;this is the inline sample function&quot;)<br>}</pre><p>the decompiled code in jvm is:</p><pre>fun example(){<br>print(&quot;example start&quot;)<br>print(&quot;this is the inline sample function&quot;)<br>print(&quot;example end&quot;)<br>}</pre><p>In the de-compiled code, the inline function is replaced by the body of the function “sample()”</p><p><strong>Advantage</strong>: Helps in reduction of function overhead.</p><p><strong>Usage</strong>: when the code inside the function is very small,inline is used.</p><p><strong>Note</strong>: when the code inside the function is large, it is not preferred to use inline since large code will be repeated again and again.</p><p>for further details/deep-diving on inline visit:</p><p><a href="https://amitshekhar.me/blog/inline-function-in-kotlin"><strong>inline function in Kotlin (amitshekhar.me)</strong></a></p><p><a href="https://stackoverflow.com/questions/44471284/when-to-use-an-inline-function-in-kotlin"><strong>when to use an inline function in Kotlin? — Stack Overflow</strong></a><strong> (see Yogesh umesh vaity’s answer).</strong></p><p><strong>3.Sealed classes :</strong></p><p>As the name suggests, sealed classes are sealed or closed. This makes them restricted.</p><p><strong>usage</strong>: Sealed classes are preferred mostly when you know what a given value will be only among a given set of options.</p><p>Confused, right? 😵😵</p><p>let’s take a look at a real-time usage example of sealed class.</p><pre>sealed class Screens(val route : String) {<br>    object Home : Screens(&quot;home_route&quot;)<br>    object Orders : Screens(&quot;orders_route&quot;)<br>    object Payments : Screens(&quot;payments_route&quot;)<br>    object Profile : Screens(&quot;profile_route&quot;)<br>}</pre><p>In the above example, the sealed class “Screens” is used as routes helper in Navigation component in jetpack compose.</p><p>In an app, we already know the screens of an app. So sealed class is preferred to choose a screen among a given set of options. (I hope this example justifies the above statement: Sealed classes are preferred mostly when you know what a given value will be only among a given set of options.)</p><p>Advantages:</p><p>i) Sealed classes prevent inheritance.</p><p>ii) The methods in the sealed class can’t be manipulated from other classes. This prevents security issues.</p><p>for more examples and elaborated explanation on sealed class visit:</p><p><a href="https://www.digitalocean.com/community/tutorials/kotlin-sealed-class">Kotlin Sealed Class | DigitalOcean</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=052f60ec5f47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[In-App Update in Android (STP)]]></title>
            <link>https://medium.com/@vishnutejareddy10/in-app-update-in-android-stp-6dd2477d8d8f?source=rss-21c4e2251753------2</link>
            <guid isPermaLink="false">https://medium.com/p/6dd2477d8d8f</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Vishnutejareddy]]></dc:creator>
            <pubDate>Thu, 04 Jan 2024 16:33:47 GMT</pubDate>
            <atom:updated>2024-01-04T16:33:47.761Z</atom:updated>
            <content:encoded><![CDATA[<p>First things first,STP stands for Straight to the Point</p><p>The users/customers using our app might have turned off the auto app update feature in playstore,Thus the updates that we publish on play store might not be known and hence the user will be on the same buggy/old version</p><p>To counter this,google playstore introduced inapp update feature.With this feature, we can easily show a prompt to the user on launching the app about the update.</p><p>There are 2 types of in-app update modes:</p><p>1.Flexible Update (Users can choose whether to update or not)</p><p>2.Immediate Update (Users must update the app to use it further)</p><p>Implementation:</p><p>1.Add Dependency</p><blockquote>implementation(“com.google.android.play:app-update-ktx:2.1.0”)</blockquote><p>2.Create AppUpdateManager instance</p><p>in onCreate() of Activity</p><blockquote>val appUpdateManager: AppUpdateManager? = AppUpdateManagerFactory.create(this)</blockquote><p>3.Check if there is an Update Available</p><p>We will request update i.e show the update prompt only if there is an update available after checking.</p><pre>private fun checkUpdate() {<br>    val appUpdateInfoTask = appUpdateManager?.appUpdateInfo<br>    appUpdateInfoTask?.addOnSuccessListener { appUpdateInfo -&gt;<br>        // This example applies an flexible update. To apply a immediate update<br>        // instead, pass in AppUpdateType.IMMEDIATE<br>        if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE<br>            &amp;&amp; appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)<br>        ) {<br>            try {<br>                appUpdateManager?.startUpdateFlowForResult(<br>                    // Pass the intent that is returned by &#39;getAppUpdateInfo()&#39;.<br>                    appUpdateInfo,<br>                    // an activity result launcher registered via registerForActivityResult<br>                    updateResultStarter,<br>                    //pass &#39;AppUpdateType.FLEXIBLE&#39; to newBuilder() for<br>                    // flexible updates.<br>                    AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build(),<br>                    // Include a request code to later monitor this update request.<br>                    UPDATE_REQUEST_CODE<br>                )<br>            } catch (exception: IntentSender.SendIntentException) {<br>                Toast.makeText(this, &quot;Something wrong went wrong!&quot;, Toast.LENGTH_SHORT).show()<br>            }<br><br>        } else {<br>            Log.d(TAG, &quot;No Update available&quot;)<br>        }<br>    }<br>}</pre><p>4.Launcher to get the update status</p><p>After the user clicks on update,It shows the status of the update via dialog.</p><pre>private val updateLauncher = registerForActivityResult(<br>    ActivityResultContracts.StartIntentSenderForResult()<br>) { result -&gt;<br>    // handle callback<br>    if (result.data == null) return@registerForActivityResult<br>    if (result.resultCode == UPDATE_REQUEST_CODE) {<br>        Toast.makeText(this, &quot;Downloading stated&quot;, Toast.LENGTH_SHORT).show()<br>        Log.i(&quot;updateLauncher&quot;,&quot;Downloading started..&quot;)<br>        if (result.resultCode != Activity.RESULT_OK) {<br>            Toast.makeText(this, &quot;Downloading failed&quot; , Toast.LENGTH_SHORT).show()<br>        }<br>    }<br>}</pre><p>5.Requesting the update(if available)</p><pre>try {<br>    appUpdateManager?.startUpdateFlowForResult(<br>        // Pass the intent that is returned by &#39;getAppUpdateInfo()&#39;.<br>        appUpdateInfo,<br>        // an activity result launcher registered via registerForActivityResult<br>        updateResultStarter,<br>        //pass &#39;AppUpdateType.FLEXIBLE&#39; to newBuilder() for<br>        // flexible updates.<br>        AppUpdateOptions.newBuilder(AppUpdateType.IMMEDIATE).build(),<br>        // Include a request code to later monitor this update request.<br>        UPDATE_REQUEST_CODE<br>    )<br>} catch (exception: IntentSender.SendIntentException) {<br>                    Toast.makeText(this, &quot;Something wrong went wrong!&quot;, Toast.LENGTH_SHORT).show()<br>}</pre><p>Define IntentSenderForResultStarter</p><pre>private val updateResultStarter =<br>    IntentSenderForResultStarter { intent, _, fillInIntent, flagsMask, flagsValues, _, _ -&gt;<br>        val request = IntentSenderRequest.Builder(intent)<br>            .setFillInIntent(fillInIntent)<br>            .setFlags(flagsValues, flagsMask)<br>            .build()<br>        // launch updateLauncher<br>        updateLauncher.launch(request)<br>    }</pre><p>6.Monitor the flexible update state</p><pre> val listener = InstallStateUpdatedListener { state -&gt;<br>        // (Optional) Provide a download progress bar.<br>        if (state.installStatus() == InstallStatus.DOWNLOADING) {<br>            val bytesDownloaded = state.bytesDownloaded()<br>            val totalBytesToDownload = state.totalBytesToDownload()<br>            // Show update progress bar.<br>        }<br>        if (state.installStatus() == InstallStatus.DOWNLOADED) {<br>            Snackbar.make(<br>                findViewById(R.id.textView),<br>                &quot;New app is ready&quot;,<br>                Snackbar.LENGTH_INDEFINITE<br>            ).setAction(&quot;Restart&quot;) {<br>                appUpdateManager.completeUpdate()<br>            }.show()<br>        }<br>        // Log state or install the update.<br>    }</pre><p>7.Register the listener</p><p>In order to track update status,we need to register the listener</p><blockquote>appUpdateManager.registerListener(listener)</blockquote><p>8.we need to unregister the listener when it is no longer needed to avoid memory leaks</p><blockquote>appUpdateManager.unregisterListener(listener)</blockquote><p>The flow :</p><p>Firstly, inside onCreate() appUpdateManager is initialized and checkUpdate() is called which checks if there is an update or not</p><p>i.if there is an update available — it starts the update flow</p><p>ii.if there is no update available then it will display a log message.</p><p>For complete project on github refer:</p><p><a href="https://github.com/VISHNUONE8/InAppUpdate">VISHNUONE8/InAppUpdate (github.com)</a></p><p>For full details and info about in-app update :</p><p><a href="https://medium.com/android-news/implement-in-app-update-in-android-68892bd11e35">Implement In-app Update In Android | by Danish Amjad | AndroidPub | Medium</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6dd2477d8d8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigation Component in Android (STP)]]></title>
            <link>https://medium.com/@vishnutejareddy10/navigation-component-in-android-stp-0162461a8921?source=rss-21c4e2251753------2</link>
            <guid isPermaLink="false">https://medium.com/p/0162461a8921</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[navigation-architecture]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Vishnutejareddy]]></dc:creator>
            <pubDate>Mon, 04 Dec 2023 02:20:59 GMT</pubDate>
            <atom:updated>2023-12-27T15:55:56.698Z</atom:updated>
            <content:encoded><![CDATA[<p>First things first, STP stands for Straight ToThe Point.</p><p><strong>Navigation component</strong> is a framework for navigating between destinations like fragments, activities &amp; other components.</p><p>Use cases &amp; Advantages:</p><p>I. Used(mostly) for Navigating between the fragments.</p><p>II. Used mostly with bottom navigation bar, appbars, Navigation Drawer(swiping).</p><p>III. Makes the implementation of navigation so smooth and easier to develop.</p><p>IV. Provides good resources by default for Animations and Transitions.</p><p>V. Safe Args — comes with a Gradle plugin which provides type safety when navigating and passing data between destinations (ex: fragments).</p><p><strong>Common mistakes to avoid</strong>:</p><p>I. Add the dependencies correctly (safeargs plugin is a must If you are passing data between destinations)</p><p>II. The ids of items in Navgraph and Menu should be the same.</p><p>See Image 1(app_navigation.xml) image 2(bottom_navigation_menu.xml) and the ids are the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wVh8MDyVJuQsS2puY0kRiw.png" /><figcaption>app_navigation.xml</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*u7q5EH5sJxPZxkB4ZTidUQ.png" /><figcaption>bottom_navigation_menu.xml</figcaption></figure><p>In this Article, we are going to implement Bottom navigation using Navigation component.</p><p>There are 3 key parts in Navigation component:</p><p>I. <strong>NavHostFragment</strong> (XML View)- This is a widget that hosts the destinations of navigation graph (before this the widget &lt;Fragment was used).</p><p>Simply to say, It is like a container for all the destinations.</p><p><strong>II. Navigation Graph</strong> (Xml resource file): An xml file that contains all navigation related info.</p><p>III. <strong>NavController</strong> (Kotlin Object): This object maintains current position (destination) within the navigation graph. It is responsible for swapping/switching of destinations.</p><p>Simply as its name suggest it controls the navigation flow.</p><p><strong>Implementation Steps</strong>:</p><ol><li><strong>Add the dependencies</strong></li></ol><p>Build.gradle(project)</p><pre>buildscript {<br><br>    repositories {<br><br>        // Make sure that you have the following two repositories<br><br>        google()  // Google&#39;s Maven repository<br><br>        mavenCentral()  // Maven Central repository<br><br>    }<br><br>    dependencies {<br><br>        def nav_version = &quot;2.5.3&quot;<br><br>        classpath(&quot;androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version&quot;)<br><br>    }<br><br>}</pre><p>Build.gradle(app)</p><pre>def nav_version = &quot;2.5.3&quot;</pre><pre>implementation(&quot;androidx.navigation:navigation-fragment-ktx:$nav_version&quot;)<br><br>implementation(&quot;androidx.navigation:navigation-ui-ktx:$nav_version&quot;)</pre><p>In plugins Add:</p><pre>id &quot;androidx.navigation.safeargs.kotlin&quot;</pre><p>2. <strong>Create the destinations</strong> (here fragments)</p><p>In my case I have created the following fragments..</p><p>· HomeFragment</p><p>· OrdersFragment</p><p>· Payments Fragment</p><p>· Account Fragment</p><p>3. <strong>Bottom Navigation view &amp; Menu resource file</strong></p><p>I .Add the Bottom Navigation View to the Activity’s xml file which is home for all the destinations.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br><br>&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br><br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br><br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br><br>    android:layout_width=&quot;match_parent&quot;<br><br>    android:layout_height=&quot;match_parent&quot;<br><br>    android:orientation=&quot;vertical&quot;<br><br>    tools:context=&quot;.MainActivity&quot;&gt;<br><br><br><br>    &lt;com.google.android.material.bottomnavigation.BottomNavigationView<br><br>        android:id=&quot;@+id/bottomNavigation&quot;<br><br>        android:layout_width=&quot;match_parent&quot;<br><br>        android:layout_height=&quot;wrap_content&quot;<br><br>        app:menu=&quot;@menu/bottom_navigation_menu&quot;&gt;<br><br><br><br>    &lt;/com.google.android.material.bottomnavigation.BottomNavigationView&gt;<br><br><br><br>&lt;/LinearLayout&gt;</pre><p>II. Also create a menu directory right clicking res-&gt;New-&gt;Android Resource Directory -&gt;Resource type = menu-&gt; ok</p><p>III. right click menu -&gt;new-&gt; Menu resource file-&gt;’name as per your wish’-&gt;ok</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br><br>&lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;<br><br><br><br>    &lt;item<br><br>        android:id=&quot;@+id/homeFragment&quot;<br><br>        android:icon=&quot;@drawable/navigarion_home&quot;<br><br>        android:title=&quot;Home&quot; /&gt;<br><br>    &lt;item<br><br>        android:id=&quot;@+id/ordersFragment&quot;<br><br>        android:icon=&quot;@drawable/baseline_orders_24&quot;<br><br>        android:title=&quot;Orders&quot; /&gt;<br><br>    &lt;item<br><br>        android:id=&quot;@+id/paymentsFragment&quot;<br><br>        android:icon=&quot;@drawable/currency_rupee&quot;<br><br>        android:title=&quot;Payments&quot; /&gt;<br><br><br><br>    &lt;item<br><br>        android:id=&quot;@+id/profileFragment&quot;<br><br>        android:icon=&quot;@drawable/navigation_account&quot;<br><br>        android:title=&quot;Profile&quot; /&gt;<br><br><br><br>&lt;/menu&gt;</pre><p>4. <strong>NavHostFragment</strong></p><p>In the MainActivity layout on which we need to change the destinations add the below xml code snippet</p><pre>&lt;androidx.fragment.app.FragmentContainerView<br><br>    android:id=&quot;@+id/navigationHostFragment&quot;<br><br>    android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;<br><br>    android:layout_width=&quot;match_parent&quot;<br><br>    android:layout_height=&quot;wrap_content&quot;<br><br>    android:layout_alignParentTop=&quot;true&quot;<br><br>    android:layout_above=&quot;@id/bottomNavigation&quot;<br><br>    app:navGraph=&quot;@navigation/nav_graph&quot;<br><br>    app:defaultNavHost=&quot;true&quot;        &gt;<br><br><br>&lt;/androidx.fragment.app.FragmentContainerView&gt;</pre><p><strong>After adding Fragment container view the activity_main.xml will look like:</strong></p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br><br>&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br><br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br><br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br><br>    android:layout_width=&quot;match_parent&quot;<br><br>    android:layout_height=&quot;match_parent&quot;<br><br>    android:orientation=&quot;vertical&quot;<br><br>    tools:context=&quot;.MainActivity&quot;&gt;<br><br><br><br>    &lt;androidx.fragment.app.FragmentContainerView<br><br>        android:id=&quot;@+id/navigationHostFragment&quot;<br><br>        android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;<br><br>        android:layout_width=&quot;match_parent&quot;<br><br>        android:layout_height=&quot;wrap_content&quot;<br><br>        android:layout_alignParentTop=&quot;true&quot;<br><br>        android:layout_above=&quot;@id/bottomNavigation&quot;<br><br>        app:navGraph=&quot;@navigation/app_navigation&quot;<br><br>        app:defaultNavHost=&quot;true&quot;        &gt;<br><br><br><br>    &lt;/androidx.fragment.app.FragmentContainerView&gt;<br><br><br><br><br><br>    &lt;com.google.android.material.bottomnavigation.BottomNavigationView<br><br>        android:id=&quot;@+id/bottomNavigation&quot;<br><br>        android:layout_width=&quot;match_parent&quot;<br><br>        android:layout_height=&quot;wrap_content&quot;<br><br>        android:layout_alignParentBottom=&quot;true&quot;<br><br>        app:menu=&quot;@menu/bottom_navigation_menu&quot;&gt;<br><br><br><br>    &lt;/com.google.android.material.bottomnavigation.BottomNavigationView&gt;<br><br><br><br>&lt;/RelativeLayout&gt;</pre><p>5. <strong>Navigation Controller</strong></p><p>In the MainActivity.kt file add the following snippets</p><p>Call setNavController() from onCreate():</p><pre>private fun setNavController(){<br><br>    try{<br><br>        val navHostFragment = supportFragmentManager.findFragmentById(R.id.navigationHostFragment) as NavHostFragment<br><br>        val navController = navHostFragment.navController<br><br><br><br>        // Find reference to bottom navigation view<br><br>        val navView: BottomNavigationView = findViewById(R.id.bottomNavigation)<br><br>        // Hook your navigation controller to bottom navigation view<br><br>        navView.setupWithNavController(navController)<br><br>    } catch (e:Exception){<br>        Log.e(TAG,&quot;there is an exception${e.message.toString()}&quot;)<br>    }<br><br>}</pre><p>Now we are good to go…</p><p><a href="https://drive.google.com/file/d/1PmUg7EoKfQI7En8zGAgR1qIdFGaaP0Jh/view?usp=drive_link">Screenrecorder-2023-12-02-22-07-55-653.mp4</a></p><p>For implementation of this project, visit my GitHub.</p><p><a href="https://github.com/VISHNUONE8/NavigationComponent-BottomNavigation/tree/master">GitHub - VISHNUONE8/NavigationComponent-BottomNavigation</a></p><p>For Clear cut details and further Info ,refer Mr.singh’s Medium Article:</p><p><a href="https://medium.com/mobcoder-llc/navigation-architecture-android-jetpack-28d65c48d02">Navigation Architecture: Android Jetpack | by Nikhil Singh | Mobcoder LLC | Medium</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0162461a8921" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open pdf in WebView Android]]></title>
            <link>https://medium.com/@vishnutejareddy10/open-pdf-in-webview-android-e36f8e6a3455?source=rss-21c4e2251753------2</link>
            <guid isPermaLink="false">https://medium.com/p/e36f8e6a3455</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Vishnutejareddy]]></dc:creator>
            <pubDate>Tue, 21 Nov 2023 16:06:22 GMT</pubDate>
            <atom:updated>2023-11-21T16:18:31.977Z</atom:updated>
            <content:encoded><![CDATA[<h3>Open pdf in WebView -Android</h3><p><strong>Use cases &amp; Advantages:</strong></p><ol><li>For loading policy docs like privacy policy, shipping, return and refund policy.</li><li>For displaying a bit of navigation information that keeps updating every now and then.</li><li>For Quick view of pdfs without moving the user out of app.</li><li>No additional libraries that increase the size of Apk file.</li></ol><p>Nowadays every app has to have some privacy policy in order to be listed on Playstore/Appstore. Also, for shopping/e-commerce/food delivery apps, inside the application, policies like shipping, return &amp; refund should be shown.</p><p>So, without navigating the user out of our app, we can use WebView in android to display the pdf format docs that are uploaded on to Google drive.</p><p>Also, we can open pdfs that aren’t in google drive using the direct download links in Android WebView.</p><p><strong>To load pdf docs from google drive link:</strong></p><ol><li>Enable sharing and access to everyone with the link.</li><li>Copy the sharing link and paste it on browser (Note: The sharing link itself won’t work).</li><li>After the link opens, click on download icon and see the change in the address bar. The download link should be submitted in the loadUrl()</li></ol><p>Ex: <strong>My GDrive file sharing link:</strong> <a href="https://drive.google.com/file/d/1tJPv8QvCvDBAPYxHvLSseHAUeRqu8HiP/view?usp=drive_link">https://drive.google.com/file/d/1tJPv8QvCvDBAPYxHvLSseHAUeRqu8HiP/view?usp=drive_link</a></p><p><strong>Download link (by following step3):</strong></p><pre>https://drive.google.com/u/0/uc?id=1tJPv8QvCvDBAPYxHvLSseHAUeRqu8HiP&amp;export=download</pre><p>To load pdfs from any other websites too we need to use the direct downloadable link.</p><p>Ex. <a href="http://www.africau.edu/images/default/sample.pdf">http://www.africau.edu/images/default/sample.pdf</a></p><p><strong>Code Snippet:</strong></p><pre><br>@SuppressLint(&quot;SetJavaScriptEnabled&quot;)<br>private fun showPdfFile(imageString: String) {<br>    showProgress()<br>    pdfView.invalidate()<br>    pdfView.settings.javaScriptEnabled = true<br>    pdfView.settings.setSupportZoom(true)<br>    pdfView.settings.builtInZoomControls = true<br>    pdfView.loadUrl(&quot;http://docs.google.com/gview?embedded=true&amp;url=$imageString&quot;)<br>    pdfView.webViewClient = object : WebViewClient() {<br>        var checkOnPageStartedCalled = false<br>        override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {<br>            checkOnPageStartedCalled = true<br>        }<br><br>        override fun onPageFinished(view: WebView?, url: String?) {<br>            if (checkOnPageStartedCalled) {<br>                pdfView.loadUrl(removePdfTopIcon)<br>                hideProgress()<br>            } else {<br>                showPdfFile(imageString)<br>            }<br>        }<br>    }<br>}</pre><p>You can refer my github page for the implementation details.</p><p><a href="https://github.com/VISHNUONE8/PdfWebviewDemo/tree/master">VISHNUONE8/PdfWebviewDemo (github.com)</a></p><p><strong>References:</strong></p><p><a href="https://medium.com/@mr.kante416/pdf-in-webview-android-1380de57155c">Pdf in WebView Android. If there is a requirement to show pdf… | by Anil kumar | Medium</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e36f8e6a3455" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>