//小米手機檢測是否打開通話自動錄音:
//通過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);
//------------------------------------------------------------------------完------------------------------------------------------------------------------------