Android sendTextMessage sends two identical messages on exceution

后端 未结 4 1037
陌清茗
陌清茗 2021-01-14 07:59

I\'ve been working on an app that sends SMS-messages. The problem I have is that the sendTextMessage method sends two messages with the same content. How do I fix that?

4条回答
  •  野的像风
    2021-01-14 08:33

    This code will print out "SMS sent" when an activity returns, not when the sms is actually sent.

    public void onReceive(Context context, Intent intent) {
        switch (getResultCode()){
            case Activity.RESULT_OK:
                Log.i(TAG,"SMS sent");
                break;
    

    So what's probably happening is that another activity you have running is exiting and then returning RESULT_OK. I can't really tell though since I can see how you set up your broadcast receivers to receive.

    Problem was the firmware as reported in the answers above.

提交回复
热议问题