當我的OnCreate活動的(不是主要活動)加載廣告,每次用戶打開該活動限制插播式廣告的數量
我需要表現出間質代碼一旦打開時,一個活動,如果這個活動添加間質性再次打開,並再次不顯示任何廣告
public class MapActivity extends ActionBarActivity
{
public static final String EXTRA_POI_ID = "poi_id";
public static final String EXTRA_POI_LATITUDE = "poi_latitude";
public static final String EXTRA_POI_LONGITUDE = "poi_longitude";
public static Intent newIntent(Context context)
{
return new Intent(context, MapActivity.class);
}
public static Intent newIntent(Context context, long poiId, double poiLatitude, double poiLongitude)
{
Intent intent = new Intent(context, MapActivity.class);
// extras
intent.putExtra(EXTRA_POI_ID, poiId);
intent.putExtra(EXTRA_POI_LATITUDE, poiLatitude);
intent.putExtra(EXTRA_POI_LONGITUDE, poiLongitude);
return intent;
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
setupActionBar();
//Dgad.setTest(true);
Dgad.showRandomPopup(MapActivity.this);
// init analytics tracker
((CityGuideApplication) getApplication()).getTracker();
}
@Override
public void onStart()
{
super.onStart();
// analytics
GoogleAnalytics.getInstance(this).reportActivityStart(this);
}
@Override
public void onResume()
{
super.onResume();
}
@Override
public void onPause()
{
super.onPause();
}
@Override
public void onStop()
{
super.onStop();
// analytics
GoogleAnalytics.getInstance(this).reportActivityStop(this);
}
@Override
public void onDestroy()
{
super.onDestroy();
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
// action bar menu behaviour
switch(item.getItemId())
{
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void setupActionBar()
{
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar bar = getSupportActionBar();
bar.setDisplayUseLogoEnabled(false);
bar.setDisplayShowTitleEnabled(true);
bar.setDisplayShowHomeEnabled(true);
bar.setDisplayHomeAsUpEnabled(true);
bar.setHomeButtonEnabled(true);
}
}
只要保持一個標誌,可能在你的應用程序類 –