广点通sdk接入 _开屏广告
1:导入架包android-query-full.0.26.7.jar,GDTUnionSDK.4.8.513.jar
2:配置权限等相关操作:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<service
android:name="com.qq.e.comm.DownloadService"
android:exported="false" />
<activity
android:name="com.qq.e.ads.ADActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" />
3:kaiping.xml布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/splash_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.qq.e.union.demo.SplashActivity" >
<ImageView
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/zp_bg" />
</RelativeLayout>
4:详见Activity:
public class KaiPingAd extends Activity implements SplashADListener {
@SuppressWarnings("unused")
private SplashAD splashAD;
private ViewGroup container;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.kaiping);
container = (ViewGroup) this.findViewById(R.id.splash_container);
splashAD = new SplashAD(this, container, Constants.APPID,
Constants.SplashPosID, this);
}
@Override
public void onADPresent() {
Log.e("AD_DEMO", "SplashADPresent");
}
@Override
public void onADDismissed() {
Log.e("AD_DEMO", "SplashADDismissed");
next();
}
@Override
public void onNoAD(int arg0) {
Log.e("AD_DEMO", "LoadSplashADFail,ecode=" + arg0);
next();
}
private void next() {
this.startActivity(new Intent(this, MainPage.class));
this.finish();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK
|| keyCode == KeyEvent.KEYCODE_HOME) {
return true;
}
return super.onKeyDown(keyCode, event);
}
}
5:效果图:
![这里写图片描述](https://img-blog.csdn.net/20151217154842868)