androID:
在proj.androID\src\org\cocos2dx\enshi\wxAPI\WXEntryActivity.java目录下修改:
主要修改的地方有:
private PowerManager powerManager = null;private WakeLock wakeLock = null;
powerManager = (PowerManager) this.getSystemService(Service.POWER_SERVICE); wakeLock = this.powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,"My Lock");
onResume()方法这3个地方。。。
package org.cocos2dx.enshi.wxAPI;import org.cocos2dx.enshi.R;import androID.app.Service;import androID.content.Context;import androID.content.Intent;import androID.content.SharedPreferences;import androID.os.Bundle;import androID.os.Handler;import androID.os.PowerManager;import androID.os.PowerManager.WakeLock;import androID.util.Log; import org.cocos2dx.lua.AppActivity;public class WXEntryActivity extends AppActivity implements IWXAPIEventHandler { private static WXEntryActivity instance = null; private static Handler mloginHandler = null; private static Handler mShareUrlHandler = null; private PowerManager powerManager = null; private WakeLock wakeLock = null; // IWXAPI 是第三方app和微信通信的openAPI接口 public static IWXAPI API; public static WXEntryActivity getInstance() { if (instance == null) { instance = new WXEntryActivity(); } return instance; } @OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); powerManager = (PowerManager) this.getSystemService(Service.POWER_SERVICE); wakeLock = this.powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,"My Lock"); //是否需计算锁的数量 wakeLock.setReferenceCounted(false); if (instance == null) { new BaseSdk(this,0); this.initsdk(); } instance = this; } @OverrIDe protected voID onResume() { super.onResume(); wakeLock.acquire(); }
其次在AndroIDManifest.xml中添加常亮权限:
<!--屏幕常量-->
<uses-permission androID:name="androID.permission.WAKE_LOCK" />
IOS:
在frameworks\runtime-src\proj.ios_mac\ios\AppController.mm目录下:
在AppController.mm文件的dIDFinishLaunchingWithOptions方法里面,
[[UIApplicationsharedApplication]setStatusbarHIDden:YES];这句后面添加:
//屏幕常亮[[UIApplication sharedApplication] setIDleTimerDisabled:YES];至此结束!!! 总结
以上是内存溢出为你收集整理的cocos2d-x3.10 如何保持屏幕常亮全部内容,希望文章能够帮你解决cocos2d-x3.10 如何保持屏幕常亮所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)