-1

I tried to repackage my Android App for Blackberry 10. It worked pretty well, but the app is unable to send a SMS.

my android code:

 private void sendSMS(String phoneNumber, String message)
    {

        String SENT = "SMS_SENT";
        String DELIVERED = "SMS_DELIVERED";

        PendingIntent sentPI = PendingIntent.getBroadcast(getBaseContext(), 0,
                new Intent(SENT), 0);

        PendingIntent deliveredPI = PendingIntent.getBroadcast(getBaseContext(), 0,
                new Intent(DELIVERED), 0);

        //---when the SMS has been sent---
        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context arg0, Intent arg1) {
                switch (getResultCode()) {
                    case Activity.RESULT_OK:
                        Toast.makeText(getBaseContext(), "SMS sent",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                        Toast.makeText(getBaseContext(), "Generic failure",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_NO_SERVICE:
                        Toast.makeText(getBaseContext(), "No service",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_NULL_PDU:
                        Toast.makeText(getBaseContext()
                                , "Null PDU",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_RADIO_OFF:
                        Toast.makeText(getBaseContext()
                                , "Radio off",
                                Toast.LENGTH_SHORT).show();
                        break;
                }
            }
        }, new IntentFilter(SENT));

        //---when the SMS has been delivered---
       registerReceiver(new BroadcastReceiver() {
           @Override
           public void onReceive(Context arg0, Intent arg1) {
               switch (getResultCode()) {
                   case Activity.RESULT_OK:
                       Toast.makeText(getBaseContext(), "SMS delivered",
                               Toast.LENGTH_SHORT).show();
                       break;
                   case Activity.RESULT_CANCELED:
                       Toast.makeText(getBaseContext()
                               , "SMS not delivered",
                               Toast.LENGTH_SHORT).show();
                       break;
               }
           }
       }, new IntentFilter(DELIVERED));

        SmsManager sms = SmsManager.getDefault();
        sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
    }

manifest :

<uses-permission android:name="android.permission.SEND_SMS">
    </uses-permission>

    <uses-permission android:name="android.permission.RECEIVE_SMS"/>

    <uses-permission android:name="android.permission.READ_SMS"/>

this code is working in android and able to send to message. But it is not working in black berry. please any one help me. Thank you in advance.

kartheeki j
  • 2,206
  • 5
  • 27
  • 51
  • is there any error? What research have you done to validate the behavior and also diagnose the difference? – JoxTraex Aug 31 '15 at 06:31
  • case SmsManager.RESULT_ERROR_RADIO_OFF: Toast.makeText(getBaseContext() , "Radio off", Toast.LENGTH_SHORT).show(); – kartheeki j Aug 31 '15 at 06:31
  • "radio off" condition – kartheeki j Aug 31 '15 at 06:32
  • That means that the radio is off... so if its off how is it supposed to send the message? The radio is needed to communicate with the network and dispatch the message. This implies that a SIM is needed in order to send the respective message. – JoxTraex Aug 31 '15 at 06:32
  • @joxtraex..sorry...for that radio off,,,what shall i do? i dont know – kartheeki j Aug 31 '15 at 06:33
  • You should figure out if the device is actually activated.. if its not you cannot send a message, activated means that is associated with some carrier network and it is allowed ti dispatch messaged. – JoxTraex Aug 31 '15 at 06:34
  • it is activated...i can send messages to others – kartheeki j Aug 31 '15 at 06:35
  • How are you so sure that its actually connected to a carrier ? Also how are you sure that the radio is not off and thats its not actually sending messaged through wifi? – JoxTraex Aug 31 '15 at 06:37
  • sorry joxtraex...i am new to mobile developement. connected to carrier means? – kartheeki j Aug 31 '15 at 06:38
  • Google what SmsManager is and how Sms messages are actually sent through a network. This will get you to understand what a carrier is. As it currently stands you don't know enough to solve this problem without knowing those particular terms and what they mean. – JoxTraex Aug 31 '15 at 06:39

1 Answers1

0

ERROR_RADIO_OFF

That means that the radio is off... so if its off how is it supposed to send the message? The radio is needed to communicate with the network and dispatch the message. This implies that a SIM is needed in order to send the respective message

If the Radio is off

You should figure out if the device is actually activated.. if its not you cannot send a message, activated means that is associated with some carrier network and it is allowed to dispatch messages.

JoxTraex
  • 13,423
  • 6
  • 32
  • 45
  • i saw radio is on in bb device – kartheeki j Aug 31 '15 at 06:47
  • yes..still i am getting radio off. i need to send the sms...when there is no mobile network and wifi – kartheeki j Aug 31 '15 at 06:50
  • You can't send the message when there is no mobile.. or wifi. You don't understand how SMS sending works, Googling how this works would answer a lot of your unanswered questions. – JoxTraex Aug 31 '15 at 06:50
  • but in android i am sending message when there was no mobile data or wifi only. this is possible in android. – kartheeki j Aug 31 '15 at 06:53
  • thats not what you said. You said "i need to send the sms...when there is no mobile network and wifi" do you mean no mobile network and wifi is on and connected? Please clarify your wording, this is too confusing as is. Please do some researcha nd then update your post, its too confusing without clear wording. – JoxTraex Aug 31 '15 at 06:53
  • Also as a final point, there is no hard fast rule that says you can send sms through wifi with the normal APIs. Before saying you CAN do it, please provide evidence to backup your claim. As supplementary information read @ http://androidforums.com/threads/sendings-texts-over-wifi.578736/ – JoxTraex Aug 31 '15 at 06:58