Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7773655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:10:51+00:00 2026-06-01T17:10:51+00:00

So i added AdMob to my app and now it will not start the

  • 0

So i added AdMob to my app and now it will not start the next activity by pressing a button.
I am trying to press a button in the Main Activity so it goes to Second Activity.
It worked before i added Admob

Main Activity:

 private AdView adView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);






      // Create an ad.
      adView = new AdView(this, AdSize.BANNER, "XXXXXXXXXXXX");

      // Add the AdView to the view hierarchy. The view will have no size
      // until the ad is loaded.
      RelativeLayout layout = (RelativeLayout) findViewById(R.id.main1);
      layout.addView(adView);

      // Create an ad request. Check logcat output for the hashed device ID to
      // get test ads on a physical device.
      AdRequest adRequest = new AdRequest();
      adRequest.addTestDevice(AdRequest.TEST_EMULATOR);

      // Start loading the ad in the background.
      adView.loadAd(adRequest);
    }

    /** Called before the activity is destroyed. */
    @Override
    public void onDestroy() {
      // Destroy the AdView.
      if (adView != null) {
        adView.destroy();
      }

      super.onDestroy();







    Button next = (Button) findViewById(R.id.button1);
    next.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent myIntent = new Intent(view.getContext(), PartyRockScreen.class);
            startActivityForResult(myIntent, 0);
        }

    });
}
}

Second Activity:

private AdView adView2;

  @Override
  public void onBackPressed() {

    }
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.party);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);



          // Create an ad.
          adView2 = new AdView(this, AdSize.BANNER, "XXXXXXXXXXXX");

          // Add the AdView to the view hierarchy. The view will have no size
          // until the ad is loaded.
          RelativeLayout layout = (RelativeLayout) findViewById(R.id.party1);
          layout.addView(adView2);

          // Create an ad request. Check logcat output for the hashed device ID to
          // get test ads on a physical device.
          AdRequest adRequest = new AdRequest();
          adRequest.addTestDevice(AdRequest.TEST_EMULATOR);

          // Start loading the ad in the background.
          adView2.loadAd(adRequest);
        }

        /** Called before the activity is destroyed. */
        @Override
        public void onDestroy() {
          // Destroy the AdView.
          if (adView2 != null) {
            adView2.destroy();
          }

          super.onDestroy();









        final MediaPlayer mediaPlayer = MediaPlayer.create(getBaseContext(), R.raw.partyrock);
        mediaPlayer.start(); // no need to call prepare(); create() does that for you




        ViewFlipper mFlipper;
        mFlipper = ((ViewFlipper)findViewById(R.id.flipper));
        mFlipper.setAutoStart(true);
        mFlipper.startFlipping();
        mFlipper.setInAnimation(AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in));
        mFlipper.setOutAnimation(AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_out));

        ViewFlipper mFlipper1;
        mFlipper1 = ((ViewFlipper)findViewById(R.id.flipper1));
        mFlipper1.setAutoStart(true);
        mFlipper1.startFlipping();
        mFlipper1.setInAnimation(AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in));
        mFlipper1.setOutAnimation(AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_out));




        Button next = (Button) findViewById(R.id.button2);
        next.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                mediaPlayer.stop();                 
                Intent intent = new Intent();
                setResult(RESULT_OK, intent);
                finish();








                    }

                        });

                };
            }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:10:52+00:00Added an answer on June 1, 2026 at 5:10 pm

    Try it –

    Intent myIntent = new Intent(MainActivity.this, PartyRockScreen.class);
    startActivity(myIntent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I added adwhirl to my application with admob and mdotm and now it is
i have added the admob test in my app as the pdf instructions were
I always get an error when I start an app with an AdMob BannerAd.
I've been trying for ages to get AdMob Ads to appear in my app.
I have successfully added admob ads to my android app and can view test
i have added google admob jar, have added jar file to builtpath and also
Due to the last release of the adMob package, I have added the MessageUI
I added a navigation control to switch between views in my app. But some
I added a custom validation method to validate a password. However, it does not
I'm trying to create a class that can be added to a Layout file,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.