Hello AdMob people.
Please help me to solve an issue.
When I dynamically load AdMob by Java Code and unload,
lots of 'http'(thread name) threads still alive.
(you can find the symtom when you connect debugger).
Please fix this issue ASAP or give me a hint as any workaround.
Below are java code and layout.xml which is simple.
Please refer and fix it for me.
-----
[Java]
private AdView adView = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button_loadad =
(Button)findViewById(R.id.loadad_button);
button_loadad.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
initAdMob();
}
});
Button button_unloadad =
(Button)findViewById(R.id.unloadad_button);
button_unloadad.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
deinitAdMob();
}
});
}
@Override
public void onDestroy() {
deinitAdMob();
super.onDestroy();
}
private void deinitAdMob(){
if( adView != null ) {
FrameLayout layout =
(FrameLayout)this.findViewById(R.id.mainframe);
layout.removeView(adView);
//adView.
adView.destroy();
adView = null;
System.gc();
}
}
private void initAdMob() {
// Create the adView
adView = new AdView(this, AdSize.BANNER, "TESET_ID");
adView.setAdListener(this);
// Lookup your LinearLayout assuming it’s been given
// the attribute android:id="@+id/mainLayout"
FrameLayout layout = (FrameLayout)findViewById(R.id.mainframe);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());
}
public void onDismissScreen(Ad arg0) {
// TODO Auto-generated method stub
}
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
// TODO Auto-generated method stub
Log.d("AdSample", "fail");
deinitAdMob();
}
public void onLeaveApplication(Ad arg0) {
// TODO Auto-generated method stub
}
public void onPresentScreen(Ad arg0) {
// TODO Auto-generated method stub
}
public void onReceiveAd(Ad arg0) {
// TODO Auto-generated method stub
Log.d("AdSample", "succ");
}
-----------------------
[Layout]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="
http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Load"
android:id="@+id/loadad_button"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Unload"
android:id="@+id/unloadad_button"
/>
<FrameLayout xmlns:android="
http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/mainframe"
android:background="#ffffff">
</FrameLayout>
</LinearLayout>