Redmi手机不询问短信权限,因此不读取短信 [英] Redmi phones not asking SMS permissions and hence not reading sms

查看:130
本文介绍了Redmi手机不询问短信权限,因此不读取短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的代码:

<!-- Data SMS Receiver -->
    <receiver android:name=".otp.OTPReceiver" android:enabled="true" android:exported="true" >
        <intent-filter>
            <action android:name="android.intent.action.DATA_SMS_RECEIVED" />


            <data android:scheme="sms" />
            <data android:port="9027" />
        </intent-filter>
    </receiver>

otp.OTPReceiver是关联的BroadcastReceiver 此功能适用于Redmi设备以外的所有其他手机.在Redmi手机中,您必须手动开启自动启动& 权限应用中的其他权限(此应用处理Redmi手机中的权限).我在安装时看到Facebook,whatsapp等,询问权限.想知道如何做到这一点.

otp.OTPReceiver is the associated BroadcastReceiver This works in all other phones except Redmi devices. In Redmi phones you have to manually switch on autostart & other permissions in the Permissions app (This app handles permissions in Redmi phones). I see Facebook, whatsapp, etc. when installed asking the permissions. Would like to know how this can be done.

我看到了诸如> 这样的问题. ,它们在询问相同的问题,但均未得到答复.我尝试将android:enabled="true"android:exported="true"添加到接收器XML代码段中,如

I saw questions like this & this which are asking the same thing but both are unanswered. I tried adding android:enabled="true", android:exported="true" into the receiver xml snippet like mentioned in here. But none of those are working.

我正在使用data sms(也称为port sms).我也验证了正常的短信,并且Redmi手机上也存在问题

I'm using data sms (also known as port sms). I verified with normal sms too and the problem exists there too on Redmi phones

推荐答案

长时间尝试后,获得了MI SMS许可(通过SMS提供程序). 将此方法(内容提供者方法)添加到您的活动或片段中. 您将能够获得许可.

After Long Time of trying, Got MI SMS permission(Through SMS Provider). Add this Method (content provider method) with your activity or fragment. you will able to get permission.

private void displaySmsLog() {
    Uri allMessages = Uri.parse("content://sms/");
    //Cursor cursor = managedQuery(allMessages, null, null, null, null);  Both are same
    Cursor cursor = this.getContentResolver().query(allMessages, null,
            null, null, null);

    while (cursor.moveToNext()) {
        for (int i = 0; i < cursor.getColumnCount(); i++) {
            Log.d(cursor.getColumnName(i) + "", cursor.getString(i) + "");
        }
        Log.d("One row finished",
                "**************************************************");
    }

}

尝试一下,它对我有用.

Give it try , It worked for me.

这篇关于Redmi手机不询问短信权限,因此不读取短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆