Android startup page advertising (Tencent advertising alliance) solution and source code download
Android launch page advertising (Tencent advertising alliance)
The startup page has become the standard configuration of almost every app. Some businesses have added open screen advertising in the startup page to bring more revenue. At present, the ads on the launch page have the function of countdown, so what can we do in the process of countdown?
This article mainly includes the following two aspects
When designing the startup page, our normal practice is to create an activity to load open screen pictures or advertisements as the entry of the program. If the data is downloaded within three to five seconds, when the user clicks the skip button or the timing is over, the data has not been initialized and has entered the main page, What about the basic data needed for the main interface?
Random advertising has nothing to do with mobile
Therefore, we design the startup page and main interface into two fragments and integrate them into mainactivity. In this way, we load advertisements in the startup page, download data in the main interface, log in and other time-consuming operations. The structure of the program is as follows:
structure
01 activity_ main.xml
It contains two fragments, one for loading advertisements and the other for the main interface
02 MainActivity.java
In SplashFragment, when the ad is loaded or clicked, the dismissSplash is called to hide the SplashFragment, and the MainFragment is displayed.
03 SplashFragment.java
Tencent advertising alliance is integrated here. Click here to register. The process is relatively simple. Follow the instructions step by step. The SDK document is also more detailed.
Call activity.dismissSplash () when the advertisement is loaded. Hide it
04 MainFragment.java
In the main thread of the mainframe, a thread only is started to simulate time-consuming operations. Through the log, you can see that the thread is already executing during the countdown of the advertisement.
The above is the startup page scheme of app, which makes full use of the time to load advertisements
Code download: http://xiazai.jb51.net/201703/yuanma/BlogDemo-master (jb51.net).rar