您的位置:首页 > 其它

手机接听或拨打电话时 添加震动

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: