title: SmsMessage.createFromPdu is deprecated in android API level 23
body: <p>I am trying to read received SMS using below code, it is working below API level 23, but in API level 23 <code>createFromPdu</code> method is deprecated. In google docs it has an <a href="http://developer.android.com/reference/android/telephony/SmsMessage.html#createFromPdu(byte[],java.lang.String)" rel="noreferrer">alternate method</a> but how do I use it.</p>
  
  <pre><code>public class IncomingSms extends BroadcastReceiver {
  
  // Get the object of SmsManager
  final SmsManager sms = SmsManager.getDefault();
  
  public void onReceive(Context context, Intent intent) {
  
      // Retrieves a map of extended data from the intent.
      final Bundle bundle = intent.getExtras();
  
      try {
  
          if (bundle != null) {
  
              final Object[] pdusObj = (Object[]) bundle.get("pdus");
  
              for (int i = 0; i &lt; pdusObj.length; i++) {
  
                  SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]);
                  String phoneNumber = currentMessage.getDisplayOriginatingAddress();
  
                  String senderNum = phoneNumber;
                  String message = currentMessage.getDisplayMessageBody();
  
                  Log.i("SmsReceiver", "senderNum: " + senderNum + "; message: " + message);
  
  
                  // Show Alert
                  int duration = Toast.LENGTH_LONG;
                  Toast toast = Toast.makeText(context,
                          "senderNum: "+ senderNum + ", message: " + message, duration);
                  toast.show();
  
              } // end for loop
          } // bundle is null
  
      } catch (Exception e) {
          Log.e("SmsReceiver", "Exception smsReceiver" +e);
  
      }
  }}
  </code></pre>