2012-04-06 6 views
0

Also habe ich AdMob zu meiner App hinzugefügt und jetzt startet es nicht die nächste Aktivität per Knopfdruck. Ich versuche, eine Taste in der Hauptaktivität zu drücken, damit es zur zweiten Aktivität geht. Es funktionierte, bevor ich AdMob hinzugefügtNeue Aktivität starten, die von AdMob unterbrochen wurde?

Hauptaktivität:

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); 
     } 

    }); 
} 
} 

Zweite Aktivität:

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(); 








        } 

         }); 

       }; 
      } 
+0

mit Activity Versuchen ... –

+0

Das ist nicht war eine sehr hilfreiche Antwort .. – SnoX

Antwort

1

Try it -

+0

Nevermind es behoben .. – SnoX

+0

@SnoX, wie? Ich habe das gleiche Problem –

+0

@dhomes, Zeig mir deinen Code :-) – SnoX