Following is my code:
<!-- 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
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.
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.
Edit: 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
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.
Give it try , It worked for me.