Android 4.4 SMS: cómo insertar un mensaje en el proveedor de SMS en Android 4.4 configurando mi aplicación como aplicación de sms predeterminada

I need to insert 1 message in SMS provider in 4.4 device and my app sends one time sms for login. So i don't want to see this login sms sent in default sms provider(sent items) in android 4.4 device. As per this blog encontrar aquí

We have to set our app as default sms app before insert message to SMS provider or in order to avoid inserting sent message(1 time sms used for login)to sms provider. I have used following code to set my app as default sms app.

Intent intent = new Intent(context, Sms.Intents.ACTION_CHANGE_DEFAULT);
intent.putExtra(Sms.Intents.EXTRA_PACKAGE_NAME, context.getPackageName());
startActivity(intent);

It is not working. Can anybody please suggest me the right approach for the above requirement.

preguntado el 27 de noviembre de 13 a las 07:11

see the changes for SMS provider from Android 4.4 here developer.android.com/about/versions/android-4.4.html#Behaviors -

I have gone through above links and tried to implement it but it is not working. -

¿A qué te refieres con no trabajar? -

Not working means, It is should be showing dialog(system dialog) to user for changing app as default SMS app which is not happening. -

2 Respuestas

if (Build.VERSION.SDK_INT > 18) {
String defaultSmsPackageName = Telephony.Sms.getDefaultSmsPackage(SwippSettingsActivity.this);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, "TEXT");
sendIntent.putExtra(Intent.EXTRA_DONT_KILL_APP, false);
if (defaultSmsPackageName != null) {
          sendIntent.setPackage(defaultSmsPackageName);
}
startActivity(sendIntent);
}

respondido 29 nov., 13:05

You need to change your manifest to include the needed receivers. Though you're not using them you need to define the receivers mentioned in that blog for the system to consider your app as a default sms candidate.

Respondido el 14 de enero de 14 a las 17:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.