Cocos2d-x Android:opengl Error 0502 problem

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.