skip to Main Content

I was developing an exam score calculator app.
When I want to call AD methods,advertisements don’t show up.

Calculation process happens in OnCreate method:

public class resultActivity extends AppCompatActivity {
    public String responseId;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_result);
        /*Calculation...*/}

and other voids like:

public void requestAd() {
/*AD RQUESTING PROCESS...*/
}

and

 public void showAd() {
/*AD SHOWING PROCESS...*/
}

AD team gave me this code to call the method and it works well:

requestButton.setOnClickListener(v -> requestAd());
 showButton.setOnClickListener(v -> showAd());

But the Problem is I don’t have buttons to call them so I tried this:

public class resultActivity extends AppCompatActivity {
    public String responseId;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_result);
        requestAd();
        showAd();

        /*Calculation...*/}

But when the activity starts ads don’t show up!
The whole question is I want this methods to be called while this activity starts.
thank you.

2

Answers


  1. Chosen as BEST ANSWER

    I made another class and moved request Ad and showAd there. Then, I made an object and called the method through object. I have to mention that I changed a minor thing in requestAd but the main job was done by the object. Thank You All.


  2. Try building up the release version APK and test on it. Maybe your Ad-provider have some restrictions in debug version?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search