------ Solution ---------------------------- ----------------
reminder function was doing do, the code is a service
landlord wrote an Activity to start the service , open the service with a thread , and if the state of black start will be effective.
import android.app.KeyguardManager;
import android.app.KeyguardManager.KeyguardLock;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.util.Log;
public class ScreenService extends Service {
/ / declare Keyboard Manager
KeyguardManager mKeyguardManager = null;
/ / declare keypad lock
private KeyguardLock mKeyguardLock = null;
/ / declare Power Manager
private PowerManager pm;
private PowerManager.WakeLock wakeLock;
@ Override
public IBinder onBind (Intent arg0) {
return null;
}
@ Override
public void onCreate () {
/ / Get the power of the service
pm = (PowerManager) getSystemService (Context.POWER_SERVICE);
/ / access to system services
mKeyguardManager = (KeyguardManager) getSystemService (Context.KEYGUARD_SERVICE);
super.onCreate ();
}
@ Override
public void onStart (Intent intent, int startId) {
/ / Point shiny screen
wakeLock = pm.newWakeLock (PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
wakeLock.acquire ();
Log.i ("Log:", "------> mKeyguardLock");
/ / initialize the keyboard lock , you can lock or unlock the keypad lock
mKeyguardLock = mKeyguardManager.newKeyguardLock ("");
/ / disable the display keypad lock
mKeyguardLock.disableKeyguard ();
}
@ Override
public void onDestroy () {
wakeLock.release ();
super.onDestroy ();
}
}
remember to add the file needs to AndroidManifest
------ eference ------------------------------------ ---
upstairs positive solution .
------ eference --------------------------------------- < br>
sorry ah , single wrong, throw a tile. Oh
I tried it , first I start first with startService found so used , will find that the screen has not completely black. So I think the use bindService, specifically how to use, I did not try. Second, although the screen lit up , but did not like the normal operation as thoroughly brighten ah , this makes the screen brighter just a little brighter , or very dark . Is that right ? I use sdk9
------ eference ----------------------------------- ----
you in the Activity 's stop method stopService,
then Service is brighter screen will destory method to release mWakelock.release ();
This would not have been lit up,
As for the brightness of the screen sdk also understand that in the end did not say how bright ,
public void acquire () / / This method simply ensures that the screen will be awakened
Makes sure the device is on at the level you asked when you created the wake lock.
public void acquire (long timeout) / / parameter represents the wake-up time after time , it will automatically release the lock
Makes sure the device is on at the level you asked when you created the wake lock. The lock will be released after the given timeout.
------ eference -------------------------------- -------
learned
------ eference ------------------------ ---------------
huweilong1030, answer Awesome ah. Grateful , ha ha !
------ eference --------------------------------------- < br>
------ eference ------------------------------------ ---
light is not all that bright , but then I looked to find API, which has a parameter can be lit. Oh
------ eference ---------------------------------------
------ eference ------------------------------------ ---
learning ah , but see not quite understand , I want to achieve in the lock screen when you can press the answer key to unlock , you have any idea ah ?
------ eference --------------------------------------- < br> What ya ..., this code is just to keep the screen always wake up in order to allow the operator was not subject to the successful completion of the lock screen interrupted Bale. If you press the power button on the side of the phone , the screen is completely black out the system to sleep , ask for a state in this completely black screen , you use a service from an activity about what powermanager wake try ! ? ...
------ eference ------------------------------------- -
too Niubi . . . .
------ eference --------------------------------------- < br>
------ eference ---------------------------------------
agree ~
------ eference ---------------------------------- -----
recently used in the project , wrote an article records , you can take a look . Android screen lit ( lit ) and unlock the screen and lock
- ---- eference ---------------------------------------
landlord , api in the end what parameters in the screen can be completely lit ah, ah can be urged
------ eference ------------------------------------ ---
newWakeLock in the flag
PowerManager.SCREEN_DIM_WAKE_LOCK replaced PowerManager.SCREEN_BRIGHT_WAKE_LOCK on the line
There is a PowerManager.ON_AFTER_RELEASE is more useful feature is the literal meaning
------ eference --------------------- ------------------
floor to force too much , the program is absolutely easy to use . Extremely grateful to you for sharing .
没有评论:
发表评论