SmsManager doesn't work

561 Views Asked by At

i have issue with SmsManager...i show you my snippet:

public class AlarmReceiver extends BroadcastReceiver{

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        String phoneNumberReciver="";
        String message="";
        SmsManager sms=SmsManager.getDefault();
        sms.sendTextMessage(phoneNumberReciver, null, message, null, null);
        Toast.makeText(context, "Alarm Triggered and SMS Sent", Toast.LENGTH_LONG);

    }


}

IDE say me that SmsManager is deprecated...so what can i use instead SmsManager?

4

There are 4 best solutions below

0
On BEST ANSWER

android.telephony.gsm.SmsManager is deprecated. Just use android.telephony.SmsManager instead of it.

0
On

Use import android.telephony.SmsManager

Rest of your code seems fine.

0
On

use below import for SmsManager and permission import android.telephony.SmsManager; uses-permission android:name="android.permission.SEND_SMS"

0
On

set permission in minfest file