I have created an SMS application that shows all the messages properly and also a BroadcastReceiver
that helps in letting me know new messages on arrival.
Using the URI's help content://mms-sms/conversations?simple=true
I am able to retrieve the messages.
This is working fine even on KitKat. I can send SMS, read SMS but I am not able to delete the SMS because my App is not the default SMS app.
Question:
How do I prompt user to make the App default? I looked at this blog:
I tried the code given on it but I don't see any difference? Am I missing anything here?
Here is the code:
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= 19)
{
final String myPackageName = getPackageName();
if (!Telephony.Sms.getDefaultSmsPackage(this).equals(myPackageName))
{
// App is not default.
// Show the "not currently set as the default SMS app" interface
View viewGroup = findViewById(R.id.not_default_app);
viewGroup.setVisibility(View.VISIBLE);
// Set up a button that allows the user to change the default SMS app
button.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
Intent intent =
new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME,
myPackageName);
startActivity(intent);
}
});
}
else
{
// App is the default.
// Hide the "not currently set as the default SMS app" interface
View viewGroup = findViewById(R.id.not_default_app);
viewGroup.setVisibility(View.GONE);
}
}
Awaiting your response! Thanks!