Categories

Follow Us @web_learners

Monday, April 27, 2020

How to Make Android App fit all Screen Sizes | Webview App Development Series Part 14

April 27, 2020 1 Comments
Hi, Today I am going to show How to Make Android App fit all Screen Sizes. Last Post I have shown you How to Integrate Admob ads in Webview. Let's Start.



First, you have to go to the "AndroidManifest.xml" file for giving permission to Make Android App fit all Screen Sizes. Usually, the display of the mobile becomes small, normal, large, x-large. So, we will give all-screen supports permission. Write the following code.

Code:


Then you have to Make different files for different sizes of the display. Like in my project have a splash screen, I will make different activity file for different display sizes.

First, you have to click on the right side of the mouse, then select new-->Layout Resource File. Also, you have to give the exact same name which name has your default activity.xml file. In my case, my file name is "activity_splash.xml" in Webview App. I will provide that name in the file name scope, As you can see my splash screen has "RelativeLayout" so I have selected Root element RelativeLayout.

Then you can see on the left side has a "size" option, you need to click on that. you will see there has Small, Normal, Large, X-Large option. You have select which size you want. Then click on OK.


This way create other files. And for the landscape mode, you need to create also the same way but have written there "land" such as layout-small-land.


If you want to create a screen for a tablet, then you need to write layout-sw600dp. 600 dp used for small to 7-inch tablet screen support, for 10-inch or higher screen you need to create the same way 720dp.



Then copy the code from the original activity file, then paste the code in all the activity files in your Webview App

That's it. In the next video, the second part will be discussed which is about image fitting in Webview App according to the activity we have created here. If you face still a problem, Watch the video above and follow my guidelines. Thank you.

Saturday, April 25, 2020

App Crash Without Any Error in Code || How to Fix || Android Studio || 2020

April 25, 2020 0 Comments
Hi, Is your Android App  or Webview App getting crash on Android Studio? Also, there is no error showing in the code? 

I am going to show the simplest and easiest way to finding the reason for app crashing and also the solution. For getting useful videos, Please subscribe to my youtube channel.


You can see in the above video, my app is crashing when I am running my Webview App on Android Studio. you can see no errors appear in my code, but my app is crashing. 

For finding the reason first click on the "Logcat" from the android studio, then you will see there is opened a window. There you will select your device, then select your project, then select the "Error".

You can see there is an "Underlined Blue color word", click on that it will show the file name and the code line number where you have an error. There will also show you the reason why your app is crashing. In my case, I have a problem in the "MainActivity.java" file on 125 number line code,  My Webview App is crashing for a null object reference.


Because I have taken a variable, but I have not initialized it in OnCreate, also I have not stored my layout design o that variable but I have written function using that variable, So it is showing null object reference. 

Now I will give the object reference on that function and then will run my project again. You can see in the video this time my Webview App is running perfectly, not crashing anymore. So I have solved my app crashing problem. You can solve find your app crashing reason and solve this way.

By the way, if you want to know in your app which code is executing, what is happening in your app. you can select Debug from the Logcat. You will be able to see everything there. See you in the next post. Thank you.

Facebook Banner Ads Integration in Android App Part 2 | Admob Alternative Ad network

April 25, 2020 1 Comments
Hi Everyone, Today I am going to show you how to integrate Facebook SDK and Banner ads in the android app in the android studio.

In the Last post, I have shown how to create a Facebook business account for monetization android app. Also, we have added our app on Facebook, Added payment method, and created a banner ad unit. If you have not followed my Facebook Banner Ads integration in Android App Part 1 yet, then first complete part 1 then come to follow this post part 2. So let's start.


First, open your project with Android studio, Then go to your "build.gradle(Module: App)" file, then paste below facebook ad network dependency in the dependencies section.


Code:


Now in the "MainActivity.xml" file initialize the Facebook Ad network SDK.

Code:



Then move to the layout file "activity_main.xml" file and paste the below code, if you want to show your ads in the top of the page then paste this code above, and if you want to show your ads in the bottom of the page then paste below code bottom in the "activity_main.xml" file.



Code:


Now go to the "MainActivity.java" file, then take an AdView private variable
Code:


Then you need to paste the below code after initializing SDK code below:


Code:


To get test ads, add "IMG_16_9_APP_INSTALL#" to your placement id. Remove this when your app is ready to serve real ads.

Now you can run your project on Emulator or on your real devices. You can see there will be test ads.

if you want to run your project on Emulator, then add the below line. You will get the hashed ID that is printed to logcat when you first make a request to load an ad on a device.

Code:


After testing done, you need to remove that line also. So, before going to live your final code will be


That's it, We have successfully integrated Facebook Ads in our App. If you face any problem in coding, you can comment below. We will try our best to help you. Thank you.

Tuesday, April 21, 2020

Facebook Banner Ads integration in Android App Part 1 | Admob Alternative Ad network

April 21, 2020 0 Comments
Hi Everyone, is your AdMob account disabled or terminated? Don't worry you can use Admob alternative ad network like Applovin, Facebook, Unity, Leadbolt. I show you how to integrate these all Admob alternative ads in the android app.

Today I am going to you how to create a Facebook business account for managing monetization on the android app, Also how to add your first app in Facebook Ad Network for monetizing.

For Better understanding watch the below video and follow my step. And if you want to get more new helpful video please subscribe to my youtube channel. Let's start.



First, you need to go developers.facebook.com Then click on Login, if your computer has already logged in Facebook, then it will automatically create your Facebook developer account.



After that, you can see above have a drop-down button called "MyApps", click on that. You can see there will appear "Create app", click on that.



Then the "Create a New App ID" window will appear. There you have to give a name for app id, then contact email. After that click on "Create App ID". Then it will ask you a captcha security check.



Now your developer account and app id created. And you will see the window like the below picture. you can see in your window have an Audience Network setup option, click on "set up".


After click on "set up", Start Monetizing now this page will open. you need to click on the "Get Started" button.


if your Facebook account has already a business manager account then it will ask you to login with that account. 
For doing that you have to just select your business manager account, then click on "Next".


And you if don't have any Business account manager, in that case, click on "Create New Account". 


After that, It will show continue with your developer account. Click on the "Continue" button.



it will give you a form, there you have to fill Name, Email, Business Name, Country. After filling done, click on the "Next" button.


Then it will ask you to add your first app. There you have to write your app name. then click on the "Next" button.



After that you have to enter in your Gmail, Facebook will be sent you an email. You need to click on the "Confirm Now" button.



After that, you have to choose the platform. As my app is Android, so I will choose Android.


Then you will see there have two options, one is "App is live", another one is "App is not live". If you are already published in the google play store, then you need to enter your app URL, then click on the search icon.it will show your app. If your app has not published yet, then select "App is not live". But after published your app, you also need to enter your app URL. After that click on the "Submit" button. See the below image.



Now you can see your app is in Review, it will take 2-3 days to approve. The first step is completed, Now the second step is Ad format chooses, you can see there have Native, Native Banner, Banner, Interstitial, Banner, Medium Rectangle.


I will choose "Banner" Because I will integrate the Banner ad in my app. After selecting the ad format, you need to write a name for your banner ad unit id. I am giving the name "Banner". After that click on the "Create Placement" button. 


1st and 2nd step is successfully completed. For the third step, you need to click on that checkbox.


4th step: In the 4th step, you need to add your payment account. Click on the "Add Payment account" button". 


It will show you a form, you have to fill it. select account type "Individual", fill your country, address, phone number, etc. After filling the full form, click on the "Next" button.


Now this time you have to link your bank account. Fill the link bank form also. After that click on "Next".


After that, they will ask you to Review your Details. After reviewing click on the "Confirm" button.


Now you will see you are all set.


Now select your payment account, which you have just created. After that, click on the "Select " button.


So we have finished all the steps. 


In the next post, I will show you How to integrate Facebook Banner Ads in Android App. Thank you.

Friday, April 17, 2020

How to Integrate Admob ads in Webview| Webview App Development Series Part 13

April 17, 2020 7 Comments
Hi Everyone, Our Webview App Development Series almost completed. We have added all the basic functionality in our App. Now we will add Admob ads in our Webview app. So that we can earn from our App. Last post I have shown you How to create an Admob account. If you don't have an Admob account, you can follow my last post.

By the way, Today I will show you how to create ad units in Admob and also how to integrate ads in our Webview App. Let's Start.


First we will go to Admob. Then click on the "Sign in" button. And then login to your Admob account.


Then you need to click on "Apps" from the left menu bar. Then click on 


Then it will ask you, have you published your app on Google Play or the App store? If your App is already published then click on Yes. After that, you can see below the image you need to enter your app name, developer name or app id.  Then click on the Search button. It will show your app, then click on ADD App.


But we have not published our Webview App yet. So, we will click on "No". Then you need to write your app name, select platform 'Android or ios' app. Then click on the "ADD" button.




You will see it says Congrats! your app has been added to Admob. And they will give you an App Id. Later we will implement this App ID in our project.



Now you need to click on "Create Ad Unit", It will show you ad format like Banner, Interistials, Reward, Native Advanced. I am going to Choose Banner ads. Click on "Select".


Then you need to give a name for the ad unit name. I am writing Banner. Then click on "Create AD UNIT"



Now you will see the below image, We have added our app, also have created an ad unit. Now we will copy APP ID and Ad unit id and paste it in a text file for easy to use.




We have done everything in AdMob, Now we will move to the android studio for implementing Admob ad in our project. For doing that, First, we need to integrate SDK in our project, you can do it in 2 ways, One is using dependencies, another one is Manual Download.

I will use dependencies to integrate SDK in Webview App, First, you need to go build.gradle(Module: App),then paste below dependency.

Code:
After that click on "Sync Now".

Now move to the "AndroidManifest.xml" file. And paste the below code inside the Application tag.

Code:



Example:

Now go to "activity_main.xml" file, and then paste below code, this code is for ads layout.

Code:




I have used test ads Ad unit id. You should not test app with your real ad unit id, for testing purposes you should always test with test ads. Otherwise Admob can banned your Admob Account.

Before Build your App for publishing in Google Play Store, don't forget to replace "test ad unit id" with your real ad unit id. Otherwise Admob will only serve test ads in your app and you will not get any revenue.

Example:


After that go to "MainActivity.java" file. Now you need to take a variable first "adview".

Code:



Now copy the below code and paste it in your "MainActivity.java" file in onCreate.

Code:


Example image:




That's it. We have finished the coding. Now you can run your project. As you can see below screenshot My app is showing test ads. So we have successfully integrated Admob Ad in our Webview App. Thank you.

Tuesday, April 14, 2020

How to Create an Admob Account in 2020

April 14, 2020 0 Comments
Hi Everyone, Today I will show you How to Create an Admob Account in 2020. 



 First, you need to enter Admob. Then you will see two buttons there one is Sign in Another one is Sign up.

As we are going to create an account. So we need to click on the Sign up button.



After click sign up button, it will ask you to enter your Gmail Account. You need to enter your Gmail which doesn't have an Admob account.


Then you need to enter your Gmail password. Then click on the "Next" button.


After that you will see it says "Welcome to admob signup". Also give you a form, there you need to select your "country", "time zone", and billing "currency". 

You can select currency as USD or your country currency. This billing currency means which currency you want to withdraw. Then you need to click on the checkbox.



After that you need to click on the "Create Admob Account" button.


That's it. You have successfully created your Admob account. Thank you.

Friday, April 10, 2020

Check Internet Connection in Android App | Webview App Development Series Part 12

April 10, 2020 1 Comments
Hi Everyone, Let's continue with our webview app development series. The last post I have shown you How to upload files in Android Webview App. Till now we have added Progress Bar, Progress Dialog, Splash Screen, Pull to Refresh, Download, Upload and also some different functionality in our Webview App.

Today I am going to you How to check internet connection in our Webview App and also How to show no internet connection dialog when the internet connection is off.


First, we will design the layout in "activity_main.xml" file for showing no internet connection on our app.

For that, First of all, I will take a Relative layout inside our LinearLayout. Inside relative layout, we will take an Imageview, a Texview and a Button. 

In "ImageView" we will show our image. First I will copy my image and will paste onto "drawable" folder. Then we will write below code in activity_main.xml below the SwipeRefreshLayout which we have taken when we have done Pull to Refresh in our Webview App.

Code:


Then Below "ImageView" will take a TextView. Inside that textview we will display our text like "No Internet Connection". For that, we will take width, height, text alignment, text color, margin, id.



Code:


After that, We will take a button, the button text will "Retry" and will take id, height, margin and so on.

Code:


So the whole code will be in activity_main.xml is with SwipeRefreshLayout :

Code:


We have finished writing code in activity_main.xml.Now we will move to the "MainActivity.java". First, we will declare a Relative layout called "relativeLayout" and a button called "NointernetBtn".



Code:


After that, we will initialize them in onCreate.


Code:


Now we will write a function below onCreate. Inside that function, we will write conditions as if our mobile data is connected, then load our website in webview.

Else if wifi is connected then also load our website. Else show our no internet design what we have designed in the relative layout on activity_main.xml.


Code:


Now we will call our function "internetcheck()" in onCreate. After that, you can run your webview project, turn off your mobile data and then check you will see when mobile data or wifi is not connected it is showing our No internet page instead of the default error page.

Code:




Now we will write code for the "Retry" button in oncreate below where we have initialized our relative layout and button.


Code:


Now if you run your project again and click on the retry button, it will reload your website. As you can see we have written code for internet connection checking and it's working. And also if we click on the Retry button it is also successfully working.

But we have not fully done yet. If you notice suppose your Webview App is running then you just turn off your internet connection you will see it's showing you default error page not showing your custom error design. Because we have written function "internetcheck()", it will just check one time when our app will start. So, we will solve this problem also.

For that, We will call the override method "onReceivedError" in "WebViewClient". Inside it, will call internetcheck() function.


Code:


So the overall code will be in "MainActivity.java" with SwiperefreshLayout is:

Code:




That's it. We have done it successfully. In the Next Post, I will show you how to implement AdMob ads in Webview app. Stay tuned, Thanks.

Tuesday, April 7, 2020

Prevent Reload Website on Screen Rotation in Android App | Webview App Development Series Part 9

April 07, 2020 0 Comments
Hi, In the previous post I have shown you How to Add Exit Dialog In Android Webview App. Today I am going to show you the solution to a common problem which every beginner face during the Android app development.

That is when you will rotate your mobile phone like the portrait to landscape mode, your website will reload. I will show you how can you solve this problem in Webview App.


You need to write code in the AndroidManifest.xml file. Inside "Application" tag you can see there have <activity android:name=" your activity file name" (here you have to write below code) ></activity> . you need to add this line in your all activity tag.

Code:


So, the whole code will be in AndroidManifest.xml file is:

Code:


That's it.you test your project now. As you can see in my above video, I have successfully prevented app reload during screen orientation change. Watch my video for a better understanding for making Webview App.

Monday, April 6, 2020

How to Add Exit Dialog on Splash Screen In Webview Android App | Webview App Development Series Part 8

April 06, 2020 0 Comments
Hi, Today I will show you How to Add Exit Dialog In Webview Android App. In the previous post I have shown you How to Add Pull to Refresh in Webview App. you can check it out. By the way Let's start.



As In my app has Splash Screen, so I will implement App Exit dialog in my SplashActivity.java file.
I will write a function called onBackPressed below the "onCreate" and will set a Message for showing the user when the user will want to exit the app.

And there will be two buttons, one is "Yes" button, another one is the "No" button. If the user clicks on the "Yes" button, Webview App will exit.  and if the user clicks on the "No" button, the user will stay the current page.


Code:



So, the whole code will be in SplashActivity.java is :


Code:

And the whole code will be in activity_splash.xml is:

Code:



That's it. We have finished coding. now we will run our webview project.


As you can see in my screenshot above, It's working perfectly. Thanks.