I am new to programming in android. I have followed instruction and create a admob banner. How can I make it appear at certain intervals, and make it disappear if I want to? For example the admob banner can goes up and down at the bottom of the screen whenever it wants to. Thanks.
Edit:
I know that i can call adView.setVisibility( View.GONE );
to make the ads appear and disappear, but when i try to write it into a thread to make it appear and disappear with intervals, it just hangs there with a black screen.
Or is there anyway that admob can make their ad appear and disappear at intervals?
This is how i call the thread.
loadAdmob = new asyncAdmobProc();
loadAdmob.execute();
loadAdmob.doInBackground();//asyncAdmobProc();
The code:
//wakes up the admob
private class asyncAdmobProc extends AsyncTask<Integer , Void, Integer> {
private boolean bconthread=true;
protected Integer doInBackground(Integer... Params) {
//wakes up and disable admob
/*AdManager.setTestDevices( new String[] {
AdManager.TEST_EMULATOR, // Android emulator
"E83D20734F72FB3108F104ABC0FFC738", // My T-Mobile G1 Test Phone
} );//*/
adView = (AdView)findViewById(R.id.articleList_ads);
adView.requestFreshAd();
adView.setVisibility( View.GONE );
//while(bconthread){
adView.requestFreshAd();
ShowAd();
postDelayed();
//HideAd();
postDelayed();
//}
//call this to delete all bitmaps associated with the ad
adView.cleanup();
return 0;
}
private void HideAd()
{
// Hide the ad.
adView.setVisibility( View.GONE );
// Fade the ad in over 4/10 of a second.
AlphaAnimation animation = new AlphaAnimation( 0.0f, 1.0f );
animation.setDuration( 400 );
animation.setFillAfter( true );
animation.setInterpolator( new AccelerateInterpolator() );
adView.startAnimation( animation );//*/
}
private void ShowAd()
{
// Unhide the ad.
adView.setVisibility( View.VISIBLE );
// Fade the ad in over 4/10 of a second.
AlphaAnimation animation = new AlphaAnimation( 0.0f, 1.0f );
animation.setDuration( 400 );
animation.setFillAfter( true );
animation.setInterpolator( new AccelerateInterpolator() );
adView.startAnimation( animation );//*/
}
}