I had a very hard time with this problem, and finally I found a solution, although I only tested it above level 22 api.
You should look at additional information in the intent received. In my case, there are two keys in the optional intent bundle that are useful: “slot” and “subscription”.
Here is an example:
public class IncomingSms extends BroadcastReceiver { public void onReceive(Context context, Intent intent) {
I did not find documentation about this, so it may be device / manufacturer dependent, I can imagine that the keys are different or something like that. You can verify this by resetting the key set:
Set<string> keyset = bundle.keySet();
source share