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
Frecuentes
Visto 1,140 veces
1
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.
2 Respuestas
0
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
0
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 android android-4.4-kitkat or haz tu propia pregunta.
see the changes for SMS provider from Android 4.4 here developer.android.com/about/versions/android-4.4.html#Behaviors - Srikanth Pai
android-developers.blogspot.in/2013/10/… - Srikanth Pai
I have gone through above links and tried to implement it but it is not working. - Mallik
¿A qué te refieres con no trabajar? - hichris123
Not working means, It is should be showing dialog(system dialog) to user for changing app as default SMS app which is not happening. - Mallik