The first occurrence of this problem on Android is very common, basically because the game switch to the main interface and then cut back to cause, appear in Cocos2d-x 2.1.3-2.1.5 these versions most.
This problem occurs because of the following points:
1, long time lock screen cut back
2. Home cut-out cut back
3. Use notification to cut back
Here 1, 2 may be related to memory, it is recommended to clear the cache when OnPause, be careful not to let the game cut back in the main thread unexpectedly.
3 The problem is because today I happen to be more profound, in fact, when the notification cut back when not back to the game caused by the activity, the code of error is as follows:
Notification Notification = new Notification(r.drawable. icon , GetText (r.string. app_name ), System.currenttimemillis ());
Intent notificationintent = new Intent (This, mainactivity. Class);
Pendingintent contentintent = pendingintent.getactivity (This, 0, Notificationintent, pendingintent. Flag_update_current);
Notification. Setlatesteventinfo (this, GetText (r.string. app_name ), GetText (r.string. Heart_push ), contentintent);
Notice. Notify (Notice_tag, notification);
And the right way should be like this
Notification Notification = new Notification(r.drawable. icon , GetText (r.string. app_name ), System.currenttimemillis ());
Intent notificationintent = new Intent (This, mainactivity. Class);
Notificationintent.setaction (Intent. Action_main);
Notificationintent.addcategory (Intent. Category_launcher);
Pendingintent contentintent = pendingintent.getactivity (This, 0, Notificationintent, pendingintent. Flag_update_current);
Notification. Setlatesteventinfo (this, GetText (r.string. app_name ), GetText (r.string. Heart_push ), contentintent);
Notice. Notify (Notice_tag, notification);
The key is two lines of red code, which solves the problem.
Cocos2d-x Android:opengl Error 0502 problem