BidVertiser

Categories

Follow Us @web_learners

BidVertiser

Monday, July 5, 2021

How to Enable File Upload and Download in Android Webview App | Webview App Development Series Part 19

July 05, 2021 1 Comments

 Hi Everyone, Welcome to our mobile app developer training. As we are Converting our website to apk, in the previous tutorial we have learned How to Enable Video, Image and File Upload in Android Webview App.

And we also have learned separately How to Upload files in Android Webview App and How to Download the files in the android webview app. 

Now we will combine uploading files and downloading files code together and will implement them in one Webview app project. 

First of all, you need to add 3 permission for "access camera, write in external storage and Internet" in your AndroidManifest.xml file. 


Code:

Then, we need to take some variables, such as:

Code:


After that, we will move to the "onCreate" method, and in the "WebChromeClient" function we will write the "onShowFileChooser" function.


Code:


Now we will write code for Downloading any files in Android Webview App. First, we will write a function for file saving permission to your device.


Code:


And then we will write code for allowing download file in the Webview app.

Code:


We have finished the coding within the onCreate method, Now we will write several functions outside of the onCreate method.


Code:


That's it, we have finished coding for Uploading and downloading files in the Android webview app. Let's run the project and test.




As you can see in the above picture, Downloading any file and uploading any type of file in Webview App is working perfectly. See you in the next tutorial.

Saturday, July 3, 2021

How to upload multiple files in webview android app | Webview App Development Series Part 18

July 03, 2021 1 Comments

 Hi Mobile App Developers, In the previous video we have learned that How to Enable File upload in Android Webview app. And I told in the last video that we will learn today how to upload multiple types of files together in the Android webview app.

As we saw in the last tutorial, we are able to upload any type of file such as Audio, Video, Txt, XL, Zip, PPT, etc. But we saw that we can only select one file and upload one file at a time,  So today we will learn How to select multiple files and upload multiple files together in the Android Webview app.

We will continue with the last tutorial code, If you have not followed that tutorial yet, first follow that tutorial, then continue this tutorial. Let's Start.

First, we will take a boolean variable, we will name it multiple_files, and the value we will store is "Yes".



Code:


Now we will move to the "onShowFileChooser" function, in that function you will find we have written code for file selection, now we will write code there for multiple file selection.


Code:


These codes will help you to select multiple files at a time in the Android webview app. Now let's see what will be the full code within the "onShowFileChooser" function.

Code:


Just need to add these line of code in "onShowFileChooser" function , and all the other code of Upload file in Webview (my last tutorial) are same such as "onActivityResult", "onConfigurationChanged", "file_permission" , "create_image()", "create_video()".  Now let's run the project and check whether Multiple file selections and multiple file uploading in the Android webview app are working or not.


As you can see in the above picture, multiple file uploading working perfectly. This way you can convert your website easily. It works like website to apk converter. 

In the next, I will show you How to Enable Upload and Download in Android Webview App.

Sunday, June 27, 2021

How to Enable Video, Image and File Upload in Android Webview App | Webview App Development Series Part 16

June 27, 2021 8 Comments

 Hi, Everyone! I have got many requests and comment about "File upload not working in android webview app", also "can not uploading pdf or video file in android webview app", you all have requested me to help you for solving the problem.


Today I will solve all the problems about "How to enable or support file uploading in android webview app", "How to allow any type file uploading such as pdf, ppt, audio, video, image, txt"? anything you will be able to upload in your webview android apps. Just follow my tutorial from beginning to end. In the previous video, I have showed you How to Enable Download in Android Webview App.

So, Let's start, First of all, you need to add 3 permission for "access camera, write in external storage and Internet" in your AndroidManifest.xml file. 


Code:


After adding the permission, now need to move to the "MainActivity.java" file, now let's take 5 variable, which are: 

Code:


Let's demonstrate, why we have taken these variable,  we have taken a private static string file called "file_type", this is for storing file type we want to upload in our webview app, such as pdf, ppt, pptx, ppt, audio, video, image, doc, zip, RTF, txt, etc. 


As we want to allow all types of these files uploading in our android webview app, so we have defined file_type = "*/*". "*/*" this means it will allow all types of file uploading in the android webview app.


cam_file_data: This String variable "cam_file_data"  for storing camera file information.

ValueCallback<Uri> file_data: We have taken the "ValueCallback" variable, we have named it "file_data", this will store data after selecting the file.

ValueCallback<Uri[]> file_path: Another "ValueCallback" variable, we named it file_path, this will store file location.


Now let's move to the "onCreate" method, and will write a function method called onShowFileChooser in our setWebChromeClient, and all the necessary code will write on this function,  See the  Below Code:


Code:


Now we will write a function "onActivityResult"  for selecting the file from the Camera or SD card in android webview app.  This function will be outside of "onCreate" method. See the  Below Code:


Code:


Now we will write function called "onConfigurationChanged"

Code:


Now we will write a function "file_permission" for checking and asking for required file permissions.


Code:


We have taken a variable "photoFile"  in the "onActivityResult" function, there we have stored a function called "create_image()". Now we will create that function. 


Code:


Now we will write function for video file

Code:


We have finished the coding. Now Let's run our project and check whether any type of file is uploading in our android webview app or not.


    

Figure: How to enable file upload in webview android

As you can see from the above image, I have successfully uploaded an audio MP3 file, MP4 video file, and image. This way you will able to do android webview upload files, upload all types of files, pdf, ppt, audio, video, image, txt etc.


In the next tutorial, I will show you How to enable multiple file upload in the Android webview app.



Wednesday, January 20, 2021

How to Optimizing Ad Refresh in Mobile App Advertising

January 20, 2021 0 Comments

 Hello EveryOne, Today we will learn how to refresh ads automatically after a definite time. You can apply this code for every mobile ad network, such as AdMob, Applovin, Unity, Facebook ads, StartApp, AppColony, etc implement this code in the Webview application or in Any android application is okay. It will work for every android mobile app and every mobile ad network in Android Studio.


The code as follows:


Code:
 






In this Code, I have Set after 20 seconds new ad will automatically reload, If you want to change the time interval, you can do that. Thank you.

Monday, September 14, 2020

How to Set App icon in Android App | Webview App Development Series Part 16

September 14, 2020 0 Comments

 Hi, In the last post we have learned how to make App and image fit in all screen sizes. Today we will learn how to Set App icon in Android App or Webview App.

First, you need to right-click on "App" then click on "New" then click on "Image Asset". Follow the below picture.


After that, go to the "Background Layer", then select the asset type, you can select the color or image as a background asset type, as your wish. I will use color, you can see in the below picture, you can select any color by click on the color code, then select Choose.



After that, go to the Foreground Layer, you can set your icon with your custom image or clip art or text. I will use my app logo so I will select image as an asset type. Then click on folder icon in Path.




Then you can resize so that the icon looks perfect. Click "Next".



After click next, it will show you how your app logo looks in the Google play store. Then click on the Finish button.



That's it, now run your project again, and you can check the app icon in the emulator, you will see the app icon. So we have successfully set our app icon.




You can also follow the video for better understanding.


Monday, August 10, 2020

How to Show Exit Dialog in Android App || Exit Dialog on Home Screen

August 10, 2020 0 Comments

 Hi, In the previous post we have learned How to Show Exit Dialogue on Splash Screen in Webview App. Today we will learn How to show Exit Dialog in Home Screen (Main Activity). Let's Start.

As we will show Exit dialog in MainActivity.java, so we will set a function onBackPressed().In that onBackPressed() function we will take an if-else condition.

Code:


The "if" condition will be if our website or app can go back then it will go to the previous page,  else it will show Exit dialog. And in the exit dialog, there will be a message, such as "Do you want to Exit?" or anything you want to show to your users.


And there will also two buttons in the Exit dialog, One is the "Yes" button, another one is the "No" Button. Then we have to set "OnClickListener" on "Yes" and "No" both button. In that OnClickListener, we will define what will happen after the user clicks on buttons.


After that, we will set if the user clicks on the "yes" button app will Exit successfully. And if the users click on the "No" button the user will stay on the current page. Then have to show the alert dialog.


So all the code together will be:

Code:
 

And see the below code so that you can understand where you have put the above Exit Dialog code.


Code:
 


Now you can run your project. You can see below the image we have successfully added Exit dialog on Home Screen. Exit dialog working perfectly.


That's it. Thank you.

Monday, August 3, 2020

How to solve Manifest merger failed problem in Android Studio

August 03, 2020 0 Comments
Hi, In the last post we have learned that How to Restore Suspended Webview Apps on Google Play. Today we are going to learn How to solve "Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-20:19 to override." problem in Android Studio.



For solving the Manifest merger failed problem,  it has two methods to solve it.  Two methods are below:

The first method is:
1. Migrate your project to AndroidX project.

The second method is:
2. Don't need to Migrate the project to the AndroidX project. Write code in the Manifest file.

How to Migrate your project to AndroidX project

If you are using old android studio libraries then you have to migrate your project to the AndroidX project. For migrating to the AndroidX project you have to add the following two lines into the "Gradle.properties" file in android studio.
Code:
 
First, go to the "Gradle.properties" file, then paste the above two lines. then click on "Sync Now".  See the below images for better understanding.



 or you can migrate your project following way also. First, click on Refactor from the above menu in Android studio. Then select on Migrate to AndroidX. 

After that you will get a confirmation window, you need to click on migrate. It will ask you to do backup your project before migrating to AndroidX.you should do the backup. Then it will migrate your project to AndroidX.



Second Method:

If you don't want to migrate your project to the AndroidX project, you can follow this second method for migrating to the AndroidX project. You need to just write below two lines of code in the Manifest file in the Android studio.
Code:
 

See below image:




After that just "Sync" your project. You will see the error is gone. That's it. Thank you.

The video tutorial of  "How to solve Manifest merger failed problem in Android Studio" is here