My application uses the following code for calling default SMS application from the MainActivity:
if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
{
string defaultSmsPackageName = Telephony.Sms.GetDefaultSmsPackage(this);
Intent intent = new Intent(Intent.ActionMain);
intent.AddCategory(Intent.CategoryDefault);
intent.SetType("vnd.android-dir/mms-sms");
if (defaultSmsPackageName != null)
intent.SetPackage(defaultSmsPackageName);
StartActivity(intent);
}
else
{
Intent intent = new Intent(Intent.ActionMain);
intent.AddCategory(Intent.CategoryDefault);
intent.SetType("vnd.android-dir/mms-sms");
StartActivity(intent);
}
Default SMS application started, but when I pressed Back button I just close application window instead or returning to the MainActivity window. Can anybody explain me where I made error?