Java Admob广告未显示,我已正确设置所有代码,仍然未显示
我现在能做什么呢,我在谷歌上做过研究,我也看过StackOverflow的帖子,但我找不到任何解决方案,我该怎么解决呢。 即使是谷歌AdMob政策,我只是在一个活动中添加了一个广告,但它仍然没有显示广告Java Admob广告未显示,我已正确设置所有代码,仍然未显示,java,android,firebase,admob,Java,Android,Firebase,Admob,我现在能做什么呢,我在谷歌上做过研究,我也看过StackOverflow的帖子,但我找不到任何解决方案,我该怎么解决呢。 即使是谷歌AdMob政策,我只是在一个活动中添加了一个广告,但它仍然没有显示广告 谢谢AdMob最多需要72小时才能批准您的帐户并开始显示广告。在此之前,您可以使用测试广告 您已经编写了所有代码,但没有初始化Admob SDK的地方。在应用程序启动时使用初始化 MobileAds.initialize(getApplicationContext(), getString(R.
谢谢AdMob最多需要72小时才能批准您的帐户并开始显示广告。在此之前,您可以使用测试广告
您已经编写了所有代码,但没有初始化Admob SDK的地方。在应用程序启动时使用初始化
MobileAds.initialize(getApplicationContext(), getString(R.string.YOUR_APP_ID));
请不要仅仅因为使用了android studio标记就用它来标记问题:只有当您对IDE本身有疑问时,才应该使用android studio标记,而不是您在其中编写(或想要编写)的任何代码。另外,请不要添加代码截图。但我也测试了我以前的Admob approved帐户,在这种情况下仍然不起作用。请检查adview是否有足够的空间显示广告。如果没有,广告将不会显示。如果这不起作用,你可以检查logcat的输出,找出到底是什么问题。我测试了测试广告,它工作,但真正的广告不工作
<resources>
<string name="app_name">C A R E S : Country\'s Action Resources Exigency Services</string>
<string name="open">Open</string>
<string name="close">Close</string>
<string name="event_name">Event/Party/Restaurant/Other Name </string>
<string name="event_location">Event Address</string>
<string-array name="events">
<item>SELECT AN EVENT</item>
<item>PARTY</item>
<item>RESTAURANT</item>
<item>OTHER EVENTS</item>
</string-array>
<string name="foods">Foods</string>
<string name="btn_send">Inform Authority</string>
<string name="copyright">
Developed by 16Bit Coders
</string>
<string name="userphone">
Your Phone Number
</string>
<string name="user_login_button">
LOGIN AS USER
</string>
<string name="authority_login_button">
LOGIN AS AUTHORITY
</string>
<string name="user_email">Email</string>
<string name="user_password">Password</string>
<string name="confirm_password">Confirm Password</string>
<string name="login">LOGIN</string>
<string name="register">REGISTER</string>
<string name="fname">First Name</string>
<string name="lname">Last Name</string>
<string name="welcome_authority">Authority Login</string>
<string name="send_otp">SEND OTP</string>
<string name="verify_otp">Verify OTP</string>
<string name="enter_otp">Enter OTP</string>
<string name="enter_aadhaar">Aadhar Card Number</string>
<string-array name="gender">
<item>SELECT GENDER</item>
<item>MALE</item>
<item>FEMALE</item>
</string-array>
<string-array name="location">
<item>91</item>
</string-array>
<string name="thanks">Thank You So Much</string>
<string name="thanks2">You Just Take a Part of Helping Needy People</string>
<string name="hero">Awesome.. You are a real Hero !!</string>
<string-array name="ngo_list">
<item>Jeevan Life Seva Sangstha</item>
<item>Astha Foundation</item>
<item>AIWA NGO India</item>
<item>All India Human Rights Bureau</item>
<item>Chain Foundation</item>
<item>Helping Hand Foundation</item>
<item>Human Wellfair Foundation</item>
</string-array>
<string name="banner_ad">ca-app-pub-*******381606112/*******732</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="192dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
app:srcCompat="@drawable/logo"
tools:layout_editor_absoluteX="174dp"
tools:layout_editor_absoluteY="54dp" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".UserLoginActivity">
<Button
android:id="@+id/user_login_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="300dp"
android:layout_marginEnd="8dp"
android:background="@drawable/login_button_style"
android:elevation="10dp"
android:text="@string/user_login_button"
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/authority_login_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
android:background="@drawable/login_button_style"
android:elevation="10dp"
android:text="@string/authority_login_button"
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/user_login_button" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="@string/copyright"
app:layout_constraintBottom_toTopOf="@+id/adView2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="@+id/nestedScrollView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad"/>
</android.support.constraint.ConstraintLayout>
</android.support.design.widget.CoordinatorLayout>
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.firebase.auth.FirebaseAuth;
public class UserLoginActivity extends AppCompatActivity {
private Button btnLogin,btnAuthLogin;
private FirebaseAuth mAuth;
private AdView adview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_login);
adview = findViewById(R.id.adView2);
AdRequest adRequest = new AdRequest.Builder().build();
adview.loadAd(adRequest);
btnLogin = findViewById(R.id.user_login_button);
btnAuthLogin = findViewById(R.id.authority_login_button);
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(UserLoginActivity.this,UserLoginPage.class));
}
});
btnAuthLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent =new Intent(UserLoginActivity.this,AuthLoginPage.class);
startActivity(intent);
}
});
}
}
MobileAds.initialize(getApplicationContext(), getString(R.string.YOUR_APP_ID));