startapp das in android studio

Start App ads in Android Studio project

How to implement Startapp ads in Android Studio

How to add Start app ads in Android Studio

In this post you will learn how to add Start app ads in android studio. Startpp provide native, rewarded video, banner, interstitial, splash screen ads, back button ads and many more. In this post you will see how to add start app ads in android studio like banner, interstitial, back button and splash screen ads. So first go to Startapp website .

Note :- Now startapp & start.io website both are same. 

so first go to Startapp website. You can go startapp website direct click this link  and Sign Up

Then click add new app like image

and then your app url and  and choose you app is android and choose you app is for kids or not  and submit

then open your Android studio project and add these lines in dependency in build.gradle

implementation 'com.startapp:inapp-sdk:4.8.+'

then your build.gradle show like this. I will bold that line only that line add in build.gradle

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.rajnibhatia.startapp"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'com.startapp:inapp-sdk:4.8.+'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

then go to AndroidManifest.xml and add these lines of Internet permission and return ads  permission

<uses-permission
    android:name="android.permission.ACCESS_WIFI_STATE"
    tools:node="remove" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.INTERNET" />


<meta-data
    android:name="com.startapp.sdk.APPLICATION_ID"
    android:value="add your startapp id" />
<meta-data
    android:name="com.startapp.sdk.RETURN_ADS_ENABLED"
    android:value="false" />       // this line used if you do not want return ads

then AndroidManifest is something like this only add black color lines.

Important Note:- Please android value change to your id. i will addd my id so when u will publish your app pls used app id add  it

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.rajnibhatia.startapp">

    <uses-permission
        android:name="android.permission.ACCESS_WIFI_STATE"
        tools:node="remove" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Startapp">
        <activity android:name=".MainActivity2"></activity>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="com.startapp.sdk.APPLICATION_ID"
            android:value="205090750" />
        <meta-data
            android:name="com.startapp.sdk.RETURN_ADS_ENABLED"
            android:value="false" />
    </application>

</manifest>

Then go to your activity_main.xml and add these line dark black lines

<?xml version="1.0" encoding="utf-8"?>
<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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/greetings_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Welcome to HTML Programs App"
        android:textSize="20sp"
        />
(This text line is used for go to next activity text id will used.
 You will used any procedure of your choice)
    <Button
        android:id="@+id/button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/greetings_text_view"
        android:layout_marginTop="169dp"
        android:onClick="showGreetings"
        android:text="Simple HTML Example"
        android:textColor="@color/white"
        android:textSize="20sp" /> 
Note:-( This button is for go to next page means go to next activity )

    <com.startapp.sdk.ads.banner.Banner
        android:id="@+id/startAppBanner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true" />
</RelativeLayout>

and then go to your MainActivity.java add only dark black color text

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.startapp.sdk.adsbase.StartAppAd;

public class MainActivity extends AppCompatActivity {
    TextView textView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView = (TextView) findViewById(R.id.greetings_text_view);
        textView = findViewById(R.id.greetings_text_view);
    }
       public void showGreetings(View view) {     // this line is write for go to next activity
           String button_text;
           button_text = ((Button) view).getText().toString();
           if (button_text.equals("Simple HTML Example")) {

               Intent intent = new Intent(this, MainActivity2.class);
               startActivity(intent);
           }
       }
    @Override                         //this is your back button ad code
    public void onBackPressed() {
        StartAppAd.onBackPressed(this);
        super.onBackPressed();
    }
}

Then create new activity with layout and go to your 2nd activity_main2.xml

Note:- in this .xml file i do not write any when used click on activity_main.xml button then this activity will open and show your interstitial ads. so you will add of your choice any you will need.

and finally go to you

MainActivity2.java and add dark color lines these line for Exit, Interstitial ads

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.startapp.sdk.adsbase.AutoInterstitialPreferences;
import com.startapp.sdk.adsbase.StartAppAd;

public class MainActivity2 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        StartAppAd.showAd(this);
        StartAppAd.setAutoInterstitialPreferences(
                new AutoInterstitialPreferences()
                        .setSecondsBetweenAds(60)
        );
    }
}

Note if you do not return ads. it is activated by default so used this code

StartAppSDK.init(this, "StartApp App ID", false);

now you will try your app you banner, interstitial, back button and splash screen ads perfect working. you will  Sign Up directly here.

Importannt note:- I will write startapp id in my post you will add that part in your start app id.. when u will publish your app.

If you like my this post please share with friends  and if you want to learn how to add startapp rewarded video ads you will mention in comment. I will try to add also. and hire me for your projects www.freelancer.in/u/bhatiasahil

 

 

4 thoughts on “Start App ads in Android Studio project”

  1. Startapp ads in android studio tutorial is very good. It is very helpful. Thanks. Please also add startapp rewarded video ads in android studio.

  2. Startapp ads in Android studio post is very helpful please also add source code of that. So it is more easy to understand. Thanks

Leave a Comment

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

GET A FREE QUOTE

Open chat
1
I need help in my project