104.android 简单的检查小米手机系统和华为手机系统是否打开通话自动录音功能,跳转通话录音页面

//小米手机检测是否打开通话自动录音:

//通过ContentResolver去查询系统的value值:

private void openRecordSetting() {
    //打开小米手机自动录音功能,0是未开启,1是开启
    if ("0".equals(queryRecordSetting())){
           //跳转到开启通话自动录音功能页面
            ComponentName componentName = new ComponentName("com.android.phone", "com.android.phone.settings.CallRecordSetting");
            Intent intent = new Intent();
            intent.setComponent(componentName);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            Toast.makeText(getContext(), "请打开通话自动录音功能", Toast.LENGTH_LONG).show();
        }
}

private String queryRecordSetting() {//查询value值
    try {
        Uri uri = Uri.parse("content://settings/system/button_auto_record_call");
        Cursor cursor = getContext().getContentResolver().query(uri, null, null, null, null);
        assert cursor != null;
        while (cursor.moveToNext()) {
            String id = cursor.getString(cursor.getColumnIndex("_id"));
            String name = cursor.getString(cursor.getColumnIndex("name"));
            String value = cursor.getString(cursor.getColumnIndex("value"));
            return value;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}

//华为手机检测是否打开通话自动录音:

//通过ContentResolver去查询系统的key值:

private int key;

private void setHW() {
        if (Build.MODEL.equals("HRY-AL00a")) {//华为手机
            try {
                key = Settings.Secure.getInt(getContext().getContentResolver(), "enable_record_auto_key");
            } catch (Settings.SettingNotFoundException e) {
                e.printStackTrace();
            }
            if (key == 0) {//0代表华为自动录音未开启
                //逻辑处理
            } else if (key == 1) {//1代表华为自动录音已开启
               //逻辑处理
            }
    }
}

 

//跳转到华为手机开启电话录音功能页面:

ComponentName componentName = new ComponentName("com.android.phone", "com.android.phone.MSimCallFeaturesSetting");
Intent intent = new Intent();
intent.setComponent(componentName);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

 //跳转到小米手机开启电话录音功能页面:

ComponentName componentName = new ComponentName("com.android.phone", "com.android.phone.settings.CallRecordSetting");
Intent intent = new Intent();
intent.setComponent(componentName);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

 

//------------------------------------------------------------------------完------------------------------------------------------------------------------------

你可能感兴趣的:(android)