android:@H_403_5@
在proj.android\src\org\cocos2dx\enshi\wxapi\WXEntryActivity.java目录下修改:@H_403_5@
@H_403_5@
private PowerManager powerManager = null;
private WakeLock wakeLock = null;
@H_403_5@
powerManager = (PowerManager) this.getSystemService(Service.POWER_SERVICE);
wakeLock = this.powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,"My Lock");
@H_403_5@
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" />
@H_403_5@
IOS:@H_403_5@
在frameworks\runtime-src\proj.ios_mac\ios\AppController.mm目录下:@H_403_5@
在AppController.mm文件的didFinishLaunchingWithOptions方法里面,@H_403_5@
[[UIApplicationsharedApplication]setStatusBarHidden:YES];这句后面添加:@H_403_5@
//屏幕常亮 [[UIApplication sharedApplication] setIdleTimerDisabled:YES];至此结束!!! 原文链接:https://www.f2er.com/cocos2dx/338664.html