I want to add banner in my Android application using StartApp SDK. Also I need to hide banner after click. How to intercept click on banner?
setonclicklistener?
No, it doesn’t fire on click.
i fixed this issue , but i have the solution in my workplace , i will try to post it tomorrow
I never heard about AdBoost. Is it trusted network? Is they take fee as a mediator?
Please, can you post the solution, Thanks!!!
It’s a mediation solution, not an ad network. They don’t take fees.
I find the solution. It is not perfect, but working. May be it will helpful for somebody.
- Create new class SAAddView.java:
package ru.bartwell.myapp;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
public class SAAddView extends View {
private OnClickListener mMyClickListener;
public SAAddView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public SAAddView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SAAddView(Context context) {
super(context);
}
public void setMyClickListener(OnClickListener l) {
mMyClickListener=l;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
mMyClickListener.onClick(this);
performClick();
return false;
}
@Override
public boolean performClick () {
return super.performClick();
}
}
- Add this code in layout XML:
<FrameLayout
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="bottom|center" >
<com.startapp.android.publish.banner.Banner
android:id="@+id/saBanner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<ru.bartwell.myapp.SAAddView
android:id="@+id/saTopLayer"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
- Add this in your activity class:
((SAAddView)mainLayout.findViewById(R.id.saTopLayer)).setMyClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Click handling here
}
});