android手机关机锁屏音
来源:互联网 发布:淘宝优惠款 编辑:程序博客网 时间:2024/04/26 01:39
android机器默认关机有锁屏音,播放这个声音的函数在KeyguardViewMediator.java playSounds函数,只需要定义一个变量,接收到系统关机广播时,调用这个函数的时候直接返回就OK了。
private boolean mCanPlaySound = true; // add for bestone
private void playSounds(boolean locked) {
// User feedback for keyguard.
if (mSuppressNextLockSound) {
mSuppressNextLockSound = false;
return;
}
// start add for bestone
if(!mCanPlaySound)
{
return;
}
// end add for bestone
final ContentResolver cr = mContext.getContentResolver();
if (Settings.System.getInt(cr, Settings.System.LOCKSCREEN_SOUNDS_ENABLED, 1) == 1)
{
final String whichSound = locked
? Settings.System.LOCK_SOUND
: Settings.System.UNLOCK_SOUND;
final String soundPath = Settings.System.getString(cr, whichSound);
if (soundPath != null) {
final Uri soundUri = Uri.parse("file://" + soundPath);
if (soundUri != null) {
final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri);
if (sfx != null) {
sfx.setStreamType(AudioManager.STREAM_SYSTEM);
sfx.play();
} else {
Xlog.d(TAG, "playSounds: failed to load ringtone from uri: " + soundUri);
}
} else {
Xlog.d(TAG, "playSounds: could not parse Uri: " + soundPath);
}
} else {
Xlog.d(TAG, "playSounds: whichSound = " + whichSound + "; soundPath was null");
}
}
}
private BroadcastReceiver mBroadCastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (action.equals(DELAYED_KEYGUARD_ACTION)) {
int sequence = intent.getIntExtra("seq", 0);
if (false) Xlog.d(TAG, "received DELAYED_KEYGUARD_ACTION with seq = "
+ sequence + ", mDelayedShowingSequence = " + mDelayedShowingSequence);
if (mDelayedShowingSequence == sequence) {
// Don't play lockscreen SFX if the screen went off due to
// timeout.
mSuppressNextLockSound = true;
doKeyguard();
}
} else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
mPhoneState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (TelephonyManager.EXTRA_STATE_IDLE.equals(mPhoneState) // call ending
&& !mScreenOn // screen off
&& mExternallyEnabled) { // not disabled by any app
// note: this is a way to gracefully reenable the keyguard when the call
// ends and the screen is off without always reenabling the keyguard
// each time the screen turns off while in call (and having an occasional ugly
// flicker while turning back on the screen and disabling the keyguard again).
if (DEBUG) Xlog.d(TAG, "screen is off and call ended, let's make sure the "
+ "keyguard is showing");
doKeyguard();
}
}
// start add for bestone
else if(action.equals(Intent.ACTION_SHUTDOWN))
{
mCanPlaySound = false;
}
// end add for bestone
/*else if(action.equals(Intent.ACTION_SHUTDOWN)){
Xlog.d("wgao","ACTION_SHUTDOWN ~~~");
showDown_gotoSleep = true;
}else if(action.equals(IPO_ENABLE)){
Xlog.d("wgao","ACTION_SHUTDOWN_IPO ~~~");
showDown_gotoSleep = true;
}else if(action.equals(IPO_DISABLE)){
Xlog.d("wgao","ACTION_BOOT_IPO ~~~");
showDown_gotoSleep = false;
}*/
}
};
- android手机关机锁屏音
- Android手机获取root权限,实现关机重启
- Android 手机中不能播放关机动画和铃声?
- 手机远程关机
- 通过手机远程关机
- 通过手机远程关机
- 通过手机远程关机
- Android 关机
- android 关机
- JAVA手机控制电脑关机
- 手机控制电脑关机程序
- 用安卓手机控制电脑关机
- 修改Android关机电量和关机温度
- 修改Android关机电量和关机温度 .
- android系统关机流程
- android系统关机流程
- 定制android 关机 画面
- 定制Android关机界面
- oj 2746 约瑟夫问题
- ZOJ 1001 A + B Problem
- iOS 开发 入门:发布应用到App Store 详细教程
- java访问数据库
- Android文件的下载
- android手机关机锁屏音
- java面试要点---ArrayList list = new ArrayList(); 在这个泛型为Integer的ArrayList中存放一个String类型的对象。
- Android基于WIFI实现电脑和手机间数据传输的技术方案研究
- express 调用coffeescripts 模板
- 如何阻止华为网盘插件修改搜狗浏览器主页
- 关于蓝屏错误IRQL_NOT_LESS_OR_EQUAL
- 递归
- 开源社区中的3个灵魂人物。
- linux下jdk1.7.0的配置