我正在开发一个android应用程序,其中我试图通过广告侦听器设置按钮的可见性。有两个活动
1)MainActivity-包含2个按钮button1和button3,WebView和非页内广告。 另一个活动是AdActivity,上面有一个不可见的按钮。我想让插页式广告的广告监听器可以看到该按钮。
JsonParsingFeedBack
MobileAds.initialize(this,"ca-app-pub-3940256099942544~3347511713");
mAdview = (AdView)findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdview.loadAd(adRequest);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(interstitialAd.isLoaded())
{
interstitialAd.show();
}
else
{
Intent intent = new Intent(MainActivity.this,AdActivity.class);
startActivity(intent);
}
}
});
interstitialAd.setAdListener(new AdListener()
{
@Override
public void onAdClicked() {
Intent nextActivity = new Intent(MainActivity.this, AdActivity.class);
Bundle bundle = new Bundle();
bundle.putInt("VAL", 1);
nextActivity.putExtras(bundle);
startActivity(nextActivity);
}
}
);
}
}
答案 0 :(得分:0)
在Bundle
中传递值:
Intent intent = new Intent(A.this, B.class);
Bundle extras = new Bundle();
extras.putString("VAL", 1 + "");
intent.putExtras(extras);
startActivity(intent);
从Bundle
获取价值:
Bundle extras = getIntent().getExtras();
String strVal = extras.getString("VAL");
int intVal = Integer.parseInt(strVal);