104.android 简单的检查小米、华为、OPPO、VIVO手机系统是否打开通话自动录音功能,跳转通话录音页面,安卓怎么检查开启通话自动录音,安卓开启自动录音

本文详细介绍了如何在小米、OPPO、VIVO及华为等主流手机品牌中检查自动录音功能是否开启,并提供了跳转至自动录音设置页面的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.各手机检查是否开启自动录音代码如下:

/**
 * 检查小米手机自动录音功能是否开启,true已开启  false未开启
 *
 * @return
 */
private boolean checkXiaomiRecord() {
    try {
        int key = Settings.System.getInt(RecordApp.context.getContentResolver(), "button_auto_record_call");
        XLog.d(TAG, "Xiaomi key:" + key);
        //0是未开启,1是开启
        return key != 0;
    } catch (Settings.SettingNotFoundException e) {
        e.printStackTrace();
    }
    return true;
}

/**
 * 检查OPPO手机自动录音功能是否开启,true已开启  false未开启
 *
 * @return
 */
private boolean checkOppoRecord() {
    try {
        int key = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1 ? Settings.Global.getInt(RecordApp.context.getContentResolver(), "oppo_all_call_audio_record") : 0;
        XLog.d(TAG, "Oppo key:" + key);
        //0代表OPPO自动录音未开启,1代表OPPO自动录音已开启
        return key != 0;
    } catch (Settings.SettingNotFoundException e) {
        e.printStackTrace();
    }
    return true;
}

/**
 * 检查VIVO自动录音功能是否开启,true已开启  false未开启
 *
 * @return
 */
private boolean checkVivoRecord() {
    try {
        int key = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1 ? Settings.Global.getInt(RecordApp.context.getContentResolver(), "call_record_state_global") : 0;
        XLog.d(TAG, "Vivo key:" + key);
        //0代表VIVO自动录音未开启,1代表VIVO所有通话自动录音已开启,2代表指定号码自动录音
        return key == 1;
    } catch (Settings.SettingNotFoundException e) {
        e.printStackTrace();
    }
    return true;
}

/**
 * 检查华为手机自动录音功能是否开启,true已开启  false未开启
 *
 * @return
 */
private boolean checkHuaweiRecord() {
    try {
        int key = Settings.Secure.getInt(RecordApp.context.getContentResolver(), "enable_record_auto_key");
        XLog.d(TAG, "Huawei key:" + key);
        //0代表华为自动录音未开启,1代表华为自动录音已开启
        return key != 0;
    } catch (Settings.SettingNotFoundException e) {
        e.printStackTrace();
    }
    return true;
}

2.各手机跳转到开启自动录音页面如下:

/**
 * 跳转到VIVO开启通话自动录音功能页面
 */
private void startVivoRecord() {
    ComponentName componentName = new ComponentName("com.android.incallui", "com.android.incallui.record.CallRecordSetting");
    Intent intent = new Intent();
    intent.setComponent(componentName);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    RecordApp.context.startActivity(intent);
    ToastUtil.getInstance().showToast("请打开VIVO通话自动录音功能");
}

/**
 * 跳转到小米开启通话自动录音功能页面
 */
private void startXiaomiRecord() {
    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);
    RecordApp.context.startActivity(intent);
    ToastUtil.getInstance().showToast("请打开小米通话自动录音功能");
}

/**
 * 跳转到华为开启通话自动录音功能页面
 */
private void startHuaweiRecord() {
    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);
    RecordApp.context.startActivity(intent);
    ToastUtil.getInstance().showToast("请打开华为通话自动录音功能");
}

/**
 * 跳转到OPPO开启通话自动录音功能页面
 */
private void startOppoRecord() {
    ComponentName componentName = new ComponentName("com.android.phone", "com.android.phone.OppoCallFeaturesSetting");
    Intent intent = new Intent();
    intent.setComponent(componentName);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    RecordApp.context.startActivity(intent);
    ToastUtil.getInstance().showToast("请打开OPPO通话自动录音功能");
}

3.查找对应的key值如下:

//Settings下的 System 、Secure 、Global下的key和value遍历打印查看:

//1.Secure
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    Cursor cursor = RecordApp.context.getContentResolver().query(Settings.Secure.CONTENT_URI, null, null, null);
    String[] columnNames = cursor.getColumnNames();
    StringBuilder builder = new StringBuilder();
    while (cursor.moveToNext()) {
        for (String columnName : columnNames) {
            String string = cursor.getString(cursor.getColumnIndex(columnName));
            builder.append(columnName).append(":").append(string).append("\n");
        }
    }
    Log.e(TAG, builder.toString());
}

//2.Global
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    Cursor cursor = RecordApp.context.getContentResolver().query(Settings.Global.CONTENT_URI, null, null, null);
    String[] columnNames = cursor.getColumnNames();
    StringBuilder builder = new StringBuilder();
    while (cursor.moveToNext()) {
        for (String columnName : columnNames) {
            String string = cursor.getString(cursor.getColumnIndex(columnName));
            builder.append(columnName).append(":").append(string).append("\n");
        }
    }
    Log.e(TAG, builder.toString());
}

//3.System
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    Cursor cursor = RecordApp.context.getContentResolver().query(Settings.System.CONTENT_URI, null, null, null);
    String[] columnNames = cursor.getColumnNames();
    StringBuilder builder = new StringBuilder();
    while (cursor.moveToNext()) {
        for (String columnName : columnNames) {
            String string = cursor.getString(cursor.getColumnIndex(columnName));
            builder.append(columnName).append(":").append(string).append("\n");
        }
    }
    Log.e(TAG, builder.toString());
}


//有时候数据太多 打印不全 使用以下方式打印:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            Cursor cursor = RecordApp.context.getContentResolver().query(Settings.System.CONTENT_URI, null, null, null);
            String[] columnNames = cursor.getColumnNames();
            while (cursor.moveToNext()) {
                for (String columnName : columnNames) {
                    String string = cursor.getString(cursor.getColumnIndex(columnName));
                    Log.e(TAG, columnName+":"+string);
                }
            }
        }

 //---------------------------------------有时间用到魅族手机再更新魅族-------------------------------------------

//----------------------------------------------------------END-------------------------------------------------------------

Android中,启动某个应用程序时需要获取相应的权限。以下是一些示例代码,用于在Android中启用自启动权限。 在AndroidManifest.xml文件中添加以下代码: ``` <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> ``` 然后,可以在Activity或Service中添加以下代码: ``` if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { Intent intent = new Intent(); intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + getPackageName())); startActivity(intent); } ``` 这段代码将打开一个名为“Battery Optimization”的设置界面。在这个设置界面中,用户可以允许应用程序在系统启动时自动启动。 注意:这段代码只能在Android 8.0及以上版本中使用。在Android 8.0以下版本中,可以使用以下代码: ``` Intent intent = new Intent(); String manufacturer = android.os.Build.MANUFACTURER; if ("xiaomi".equalsIgnoreCase(manufacturer)) { intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")); } else if ("oppo".equalsIgnoreCase(manufacturer)) { intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")); } else if ("vivo".equalsIgnoreCase(manufacturer)) { intent.setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")); } List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (list.size() > 0) { startActivity(intent); } ``` 这段代码将打开各个厂商设备的自启动管理界面,用户可以在该界面中允许应用程序在系统启动时自动启动。
评论 39
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值