如何在Android中保持屏幕?

时间:2013-05-22 11:37:45

标签: android

如何在Android中保持屏幕显示?

Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + Uri.encode("+86 212312142")));
startActivityForResult(callIntent, 100);

即使在手机拨号活动中,我希望屏幕保持开启状态。 (没有朦胧)

我试试这个

PowerManager pm = (PowerManager) act.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "XXXX");
wakeLock.acquire();

1 个答案:

答案 0 :(得分:0)

我认为您需要添加额外的权限才能使用wakelock

<uses-permission android:name="android.permission.WAKE_LOCK" />

但我建议你不要使用唤醒锁,而是使用它:

@Override
    protected void onCreate(Bundle savedBundle) {
        super.onCreate(savedBundle);

        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

这里有一个关于不使用唤醒锁的好讨论 - &gt; Force Screen On