i started my project with empty activity that was the main_activity then i added a tabbed activity then i deleted the main one so after i finished making my project i tryed every way to put admob and and build app and try it on my phone and it doesnt show anything
this is java file .
public class tap extends AppCompatActivity {
private static final String TAG = "tap";
private SectionsPageAdapter mSectionsPageAdapter;
private ViewPager mViewPager ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tap);
Log.d(TAG, "onCreate : starting");
mSectionsPageAdapter = new SectionsPageAdapter(getSupportFragmentManager());
// Set up the ViewPager with the section adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
setupViewPager(mViewPager);
TabLayout tablayout = (TabLayout) findViewById(R.id.tabs);
tablayout.setupWithViewPager(mViewPager);
}
private void setupViewPager(ViewPager viewPager) {
SectionsPageAdapter adapter = new SectionsPageAdapter(getSupportFragmentManager());
adapter.addFragment(new pharmacist(),"Ph");
adapter.addFragment(new dentist(),"Dent");
adapter.addFragment(new doctor(),"MD");
adapter.addFragment(new pook(),"on");
viewPager.setAdapter(adapter);
}
}
this is the layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:ads="http://schemas.android.com/apk/res-auto"
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:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.testpharmacist.tap">
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="50dp"
android:layout_height="25dp"
android:layout_marginTop="10dp"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
1-i finished making my project i tried every way to put admob and
build app and try it on my phone and it doesn't show the ad can any one help me .
2. where to add the banner is it in the tabbed activity only or in
the fragments and in the other activities that contain pdf viewer and web view ??
-if i didn't yet publish my app will this effect that ads doesn't appear ?
"-if i didn't yet publish my app will this effect that ads doesn't appear ?"
"-----and if i add the ad on the main tabbed activity will it stay visible when activity open by buttons from the fragments or will i have to add them to those activities individually ?"
package com.testpharmacist:
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.Spinner;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.MobileAds;
import static com.testpharmacist.R.id.container;
public class pharmacist extends Fragment {
private static final String TAG = "pharmacist";
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.pharmacist,container,false);
Button newPage = (Button) view.findViewById(R.id.t1);
newPage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), question1.class);
startActivity(intent);
}
});
Button newPage1 = (Button) view.findViewById(R.id.t2);
newPage1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), question2.class);
startActivity(intent);
}
});
Button newPage2 = (Button) view.findViewById(R.id.t3);
newPage2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), question3.class);
startActivity(intent);
}
});
Button newPage3 = (Button) view.findViewById(R.id.t4);
newPage3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), question4.class);
startActivity(intent);
}
});
Button newPage4 = (Button) view.findViewById(R.id.t5);
newPage4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), question5.class);
startActivity(intent);
}
});
Button newPage5 = (Button) view.findViewById(R.id.t6);
newPage5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), question6.class);
startActivity(intent);
}
});
Button newPage6 = (Button) view.findViewById(R.id.t7);
newPage6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), question7.class);
startActivity(intent);
}
});
Button newPage7 = (Button) view.findViewById(R.id.t8);
newPage7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), drugbank.class);
startActivity(intent);
}
});
return view;
}
}
-------------------------------------
and this is the layout :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="650dp"
android:background="@color/one" >
<LinearLayout xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:myapp="http://schemas.android.com/apk/res/com.testpharmacist"
android:background="@color/one" >
<TextView
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:textSize="22sp"
android:textStyle="bold"
android:text="All what Pharmacists need"
android:fontFamily="sans-serif-smallcaps"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:textColor="@color/three"
android:layout_height="wrap_content" />
<Button
android:fontFamily="sans-serif-smallcaps"
android:textStyle="bold"
android:layout_marginTop="7dp"
android:id="@+id/t1"
android:text="Summarized"
android:textSize="25sp"
android:textAllCaps="false"
android:layout_gravity="center"
android:background="@drawable/rounded"
android:textColor="@color/new_colors"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_marginBottom="6dp"/>
<Button
android:fontFamily="sans-serif-smallcaps"
android:textStyle="bold"
android:id="@+id/t2"
android:text="Summarized1"
android:textSize="25sp"
android:textAllCaps="false"
android:layout_gravity="center"
android:background="@drawable/rounded"
android:textColor="@color/new_colors"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_marginBottom="6dp"/>
<Button
android:fontFamily="sans-serif-smallcaps"
android:textStyle="bold"
android:id="@+id/t5"
android:text="Summarized2"
android:textSize="25sp"
android:layout_gravity="center"
android:textAllCaps="false"
android:background="@drawable/rounded"
android:textColor="@color/new_colors"
android:layout_height="40dp"
android:layout_width="200dp"
android:layout_marginBottom="6dp"/>
<Button
android:fontFamily="sans-serif-smallcaps"
android:textStyle="bold"
android:id="@+id/t3"
android:text="Questions"
android:textSize="25sp"
android:textAllCaps="false"
android:layout_gravity="center"
android:background="@drawable/rounded"
android:textColor="@color/new_colors"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_marginBottom="6dp" />
<Button
android:fontFamily="sans-serif-smallcaps"
android:textStyle="bold"
android:id="@+id/t4"
android:text="Questions1"
android:textSize="25sp"
android:layout_gravity="center"
android:textAllCaps="false"
android:background="@drawable/rounded"
android:textColor="@color/new_colors"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_marginBottom="6dp" />
<Button
android:fontFamily="sans-serif-smallcaps"
android:textStyle="bold"
android:id="@+id/t7"
android:text="Questions2"
android:textSize="25sp"
android:layout_gravity="center"
android:textAllCaps="false"
android:background="@drawable/rounded"
android:textColor="@color/new_colors"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_marginBottom="6dp"/>
<Button
android:fontFamily="sans-serif-smallcaps"
android:textStyle="bold"
android:id="@+id/t6"
android:text="Calculation"
android:textSize="25sp"
android:textAllCaps="false"
android:layout_gravity="center"
android:background="@drawable/rounded"
android:textColor="@color/new_colors"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_marginBottom="6dp"/>
<Button
android:fontFamily="sans-serif-smallcaps"
android:textStyle="bold"
android:id="@+id/t8"
android:text="Best Online reference"
android:textSize="27sp"
android:layout_gravity="center"
android:textAllCaps="false"
android:background="@drawable/rounded"
android:textColor="@color/new_colors"
android:layout_width="250dp"
android:layout_height="wrap_content"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>