2012-04-06 5 views
0

私のアプリにAdMobを追加しましたが、今度はボタンを押して次のアクティビティを開始しません。 メインアクティビティのボタンを押してセカンドアクティビティに移動しようとしています。 私はAdmobの新しいアクティビティをAdMobで開始しますか?

主な活動を追加する前にそれが働いた:

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

    }); 
} 
} 

第二の活動:

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

ActivityGroupで試してみてください... –

+0

ませんでした非常に有益な答え.. – SnoX

答えて

1

はそれを試してみてください -

+0

決してそれを修正した.. – SnoX

+0

@SnoX、どう?私は同じ問題を持っています –

+0

@dhomes、あなたのコードを表示してください:-) – SnoX

関連する問題