How to Convert Website into Android Application step by step with addmob adds

Project Source code

Screen shot


Complete website convert into android app with Admob adds

1 step: create new project in android studio
2 step:Open activity_main.xml (or) main.xml,
create application interface and add webview element to it.

and copy paste code 

<RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android” xmlns:app=“http://schemas.android.com/apk/res-auto” xmlns:tools=“http://schemas.android.com/tools” xmlns:ads=“http://schemas.android.com/apk/res-auto” android:layout_width=“match_parent” android:layout_height=“match_parent” tools:context=“com.tech.dastgeer.dastgeertech.MainActivity”>
<WebView android:layout_below=“@+id/adView” android:id=“@+id/webview” android:layout_width=“match_parent” android:layout_height=“match_parent” >
</WebView>
<com.google.android.gms.ads.AdView xmlns:ads=“http://schemas.android.com/apk/res-auto” android:id=“@+id/adView” android:layout_width=“match_parent” android:layout_height=“wrap_content” android:layout_alignParentTop=“true” ads:adSize=“SMART_BANNER” ads:adUnitId=“ca-app-pub-6638829118614493/4690341639”>
</com.google.android.gms.ads.AdView>
</RelativeLayout>

Step 3:  Open MainActivity.java

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
public class MainActivity extends AppCompatActivity {
private AdView mAdView;
WebView webView;

 @Override 

public void onBackPressed() {

if (webView.canGoBack()) {
webView.goBack();
} else {
super.onBackPressed();
}
}
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webview);
MobileAds.initialize(this,“ca-app-pub-6638829118614493~9779016782”);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl(“https://dastgeertech.blogspot.com/”);
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
}

Step 4: Open AndroidManifest.xml file 
and give internet permission to it just after the package name. 
It is important because app data will load from website.


<uses-permission android:name=“android.permission.INTERNET”></uses-permission>
<uses-permission android:name=“android.permission.ACCESS_NETWORK_STATE”></uses-permission>

Step 5: openstrings.xml
change adunit id

<resources>
<string name=“app_name”>DastgeerTech</string>
<string name=“banner_ad_unit_id”>ca-app-pub-6638829118614493/4690341639</string>
<string name=“click_here”>click here</string>
</resources>

Step 6 : open the app-level build.gradle file for your app, and look for a “dependencies” section.

dependencies {
    implementation fileTree
(dir: 'libs', include: ['*.jar'])
    implementation
'com.android.support:appcompat-v7:26.1.0'
   
implementation 'com.google.android.gms:play-services-ads:15.0.0'}
Add the line in bold above

Click here :Website To Android App – Material Design | Full Applications With Admob

DastgeerTech

https://dastgeertech.studio/

Welcome to DastgeerTech Studio, your number one source for all things blogger template,wordpress theme & plugin,android source codes, android apps, new technology, mobile technology. We're dedicated to giving you the very best of eveything, with a focus on Quality.

Related post

5 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *