如果屏幕关闭,我编写了这段代码来唤醒我的活动。
private PowerManager mPM;
private PowerManager.WakeLock mPartialWakeLock;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//some code
mPM = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE);
if (mPM == null) {
Log.e(TAG, "PowerManager is null");
}
try {
mPartialWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK , "LOG");
mPartialWakeLock.aquire();
}
catch (Exception e) {Log.i(TAG, "mPM.newWakeLock() EXCEPTION="+e.toString());}
问题是当屏幕关闭时,应用程序被暂停。