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

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

问题描述

以下是我的代码:

<!-- 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.

我看到了诸如这个之类的问题&this 都在问同样的事情,但都没有得到答复.我尝试将 android:enabled="true", android:exported="true" 添加到 此处.但这些都不起作用.

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).我也用普通短信验证过,红米手机也存在这个问题

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 Provider).使用您的活动或片段添加此方法(内容提供程序方法).您将能够获得许可.

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.

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

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