手机接听或拨打电话时 添加震动
2013-04-11 14:53
351 查看
private CallManager mCM;
Phone fgPhone = mCM.getFgPhone();
//这里的Phone是一个系统提供的接口
//public interface Phone extends SprdVideoPhone{
// enum State {
// IDLE, RINGING, OFFHOOK;
// };
//}
//CallManager是
public final class CallManager{}
if( (fgPhone.getForegroundCall().getState() == Call.State.ACTIVE) &&
(mPreviousCallState != null &&( mPreviousCallState.isDialing() ||
mPreviousCallState==Call.State.IDLE))){
callVibrate(); //调用启动震动方法
}
private void callVibrate() {
if(SprdFeatureUtils.SPRD_APP_CALL_VIBRATE_CHANGE_DEFAULT_VALUE == true){
if (PreferenceManager.getDefaultSharedPreferences(mApplication).getBoolean(KEY_CALL_VIBRATE, false)) {
Vibrator vibrator = (Vibrator) mApplication.getSystemService(Context.VIBRATOR_SERVICE);
if (VDBG) log("call vibrate");
vibrator.vibrate(100);
}
}else{
if (PreferenceManager.getDefaultSharedPreferences(mApplication).getBoolean(KEY_CALL_VIBRATE, true)) {
Vibrator vibrator = (Vibrator) mApplication.getSystemService(Context.VIBRATOR_SERVICE);
if (VDBG) log("call vibrate");
vibrator.vibrate(100);
}
}
}
涉及到的类:CallNotifier
震动需要权限:<uses-permissionandroid:name="android.permission.VIBRATE"></uses-permission>
Phone fgPhone = mCM.getFgPhone();
//这里的Phone是一个系统提供的接口
//public interface Phone extends SprdVideoPhone{
// enum State {
// IDLE, RINGING, OFFHOOK;
// };
//}
//CallManager是
public final class CallManager{}
if( (fgPhone.getForegroundCall().getState() == Call.State.ACTIVE) &&
(mPreviousCallState != null &&( mPreviousCallState.isDialing() ||
mPreviousCallState==Call.State.IDLE))){
callVibrate(); //调用启动震动方法
}
private void callVibrate() {
if(SprdFeatureUtils.SPRD_APP_CALL_VIBRATE_CHANGE_DEFAULT_VALUE == true){
if (PreferenceManager.getDefaultSharedPreferences(mApplication).getBoolean(KEY_CALL_VIBRATE, false)) {
Vibrator vibrator = (Vibrator) mApplication.getSystemService(Context.VIBRATOR_SERVICE);
if (VDBG) log("call vibrate");
vibrator.vibrate(100);
}
}else{
if (PreferenceManager.getDefaultSharedPreferences(mApplication).getBoolean(KEY_CALL_VIBRATE, true)) {
Vibrator vibrator = (Vibrator) mApplication.getSystemService(Context.VIBRATOR_SERVICE);
if (VDBG) log("call vibrate");
vibrator.vibrate(100);
}
}
}
涉及到的类:CallNotifier
震动需要权限:<uses-permissionandroid:name="android.permission.VIBRATE"></uses-permission>
相关文章推荐
- ios客户端学习-iOS 识别文字中的手机号码高亮显示点击可拨打电话
- liblinphone实现电话拨打及接听
- Cocos2d-x添加Android手机震动
- web直接调手机拨打电话android本地配置方法
- Android中实现拨打电话、发送短信、响铃、震动和获取当前时间
- 伪基站收集方圆500至1000米范围内的手机卡信息,并且通过伪基站设备伪装成银行、中国移动、中国联通等任意号码向手机用户发送短信或拨打电话
- Android 如何判断拨打电话对方是否接听
- 微信小程序部分手机无法拨打电话的解决的方案
- iOS应用调用手机发送短信和拨打电话
- wp7手机拨打长途电话
- 手机网页点击链接触发手机自动拨打或保存电话的代码
- Cocos2d-x添加IOS手机震动
- 从手机网页拨打电话
- 伪基站收集方圆500至1000米范围内的手机卡信息,并且通过伪基站设备伪装成银行、中国移动、中国联通等任意号码向手机用户发送短信或拨打电话
- 手机网页点击链接触发手机自动拨打或保存电话的代码
- WebApp调用手机相册或摄像头、拨打电话
- 来电、接听、挂断、拨打电话
- 手机网页中 唤醒拨打电话和发送短信,浏览器和微信浏览器都可以用
- TextView添加下划线、拨打电话