One problem today is that the Game transplanted to Android displays ads on the main interface, and there are hidden ads in the game.
Let's look at my implementation methods.
1. When the game starts, a view is placed in the XML file on the Java side for advertisement placement. Initialize the ad code During oncreate.
2. After Entering the game, C ++ notifies Java through JNI (I have introduced how to use JNI) to hide the advertisement.
3. Hidden advertisements in Java:
Ui method updated in the main thread,
View Source Code
Print help
01 |
private Handler mHandler =
new Handler(){
|
03 |
public void handleMessage(Message msg) { |
06 |
// Todo handle the hidden ad adview. setvisibility (view. Invisible) here ); |
When Java receives a notification to hide the advertisement, it sends a message to update the UI.
3 |
mHandler.sendEmptyMessageDelayed(UPDATE_UI, 0); |