Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Default SMS prompt for KitKat

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!

like image 715
TheDevMan Avatar asked Jan 19 '14 03:01

TheDevMan


People also ask

What is the default SMS app on Android?

Verizon officially makes Google Messages the default messaging app for all Android phones. At the start of July, AT&T announced that it was changing the default text messaging app for all of its Android phones to Google Messages.


1 Answers

I solved by entering the following in the manifest.

The most important part we should use everything, including MMS part if not it will not work.

<!-- Activity that allows the user to send new SMS/MMS messages -->
<activity android:name=".ComposeSmsActivity" >
    <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <action android:name="android.intent.action.SENDTO" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="sms" />
        <data android:scheme="smsto" />
        <data android:scheme="mms" />
        <data android:scheme="mmsto" />
    </intent-filter>
</activity>

<!-- Service that delivers messages from the phone "quick response" -->
<service android:name=".HeadlessSmsSendService"
         android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE"
         android:exported="true" >
    <intent-filter>
        <action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="sms" />
        <data android:scheme="smsto" />
        <data android:scheme="mms" />
        <data android:scheme="mmsto" />
    </intent-filter>
</service>
like image 161
TheDevMan Avatar answered Sep 22 '22 03:09

TheDevMan