I have implemented to Send message of character length is 500,so divided into 160 character messages.
But in that it skips a few message so i added with async task,but still the problem continuous,can help me solve
here is my code,
public class SendMessage
{
public static void SendSMS(Activity activity, String Msg)
{
try {
SmsSendTask mAuthTask=null;
mAuthTask = new SmsSendTask(Msg);
mAuthTask.execute((Void) null);
} catch (Exception e) {
Toast.makeText(activity, "SMS failed, please try again.", Toast.LENGTH_LONG).show();
System.out.println(e.toString()+"<<e>>>");
e.printStackTrace();
}
}
public static class SmsSendTask extends AsyncTask<Void, Void, Boolean> {
private final String _msg;
SmsSendTask(String msg) {
_msg = msg;
}
@Override
protected Boolean doInBackground(Void... params) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
return false;
}
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("9246591931", null, _msg, null, null);
return true;
}
@Override
protected void onPostExecute(final Boolean success) {
if (success) {
} else {
}
}
@Override
protected void onCancelled() {
}
}
}