2

in agreement with the recent post from Android Developers http://android-developers.blogspot.pt/2013/10/getting-your-sms-apps-ready-for-kitkat.html ,I was trying to prepare my app to the new android version, but encountered a problem with the part they suggest to create a dialog to let the user set the app as the default application to handle SMS's :

Android Developers Post

public class ComposeSmsActivity extends Activity {

@Override
protected void onResume() {
    super.onResume();

    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 button = (Button) findViewById(R.id.change_default_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);
    }
}

}

the code itself in pretty much straightforward, but I'm unable to access to Telephony.Sms.getDefaultSmsPackage because it says that Telephony cannot be resolved, and I can't find any import or declaration that would fix that.

Can anyone please help?

Daniel Nugent
  • 43,104
  • 15
  • 109
  • 137
Pmsc
  • 318
  • 1
  • 4
  • 12

3 Answers3

2

android.provider.Telephony simply doesn't exist yet (as of API 18 - 4.3).

This class will be added in 4.4 (presumably API 19), and that blog post is highlighting the changes that you should make once the new API is released so you aren't surprised when the time comes.

From the end of the post:

To help you make the changes, we'll soon be providing the necessary SDK components for Android 4.4 that allow you to compile and test your changes on Android 4.4.

Don't forget that you should wrap this code in an API version check so you don't run into issues with older versions that don't have this class.

Bryan Herbst
  • 66,602
  • 10
  • 133
  • 120
  • Yes, you are correct! I just missed reading the last lines of the post.. =\ ! thanks anyway ! – Pmsc Oct 22 '13 at 17:14
2

this change will break all the SMS blocking apps. "Note that—beginning with Android 4.4—any attempt by your app to abort the SMS_RECEIVED_ACTION broadcast will be ignored so all apps interested have the chance to receive it."

Do you think there is a way to go around this?!

Maybe at least on Root?

user961186
  • 91
  • 2
  • 7
-2

Apparently there is with root access. The latest version Cerberus app claim to be doing this.

Now, if only I knew how they do it :(

kencorbin
  • 1,958
  • 1
  • 20
  • 18
  • 1
    This appears to be a comment rather than a standalone answer. – laalto Jan 20 '14 at 17:33
  • This was a comment to my answer. I don't see anything regarding this on the Cerberus app/website so if you can provide a link that will be great? – user961186 Mar 27 '14 at 16:50
  • What I saw was some kind comment in the recent changes section of the Play Store display. Alas, they do not seem to any kind of public change log, so this comment has long since disappeared. What I remember was that they made some change to fix SMS processing under Kit Kat for rooted devices. While trying to find some reference to this, I did stumble across the discussion where they are trying make it work. https://groups.google.com/forum/#!topic/cerberus-support-forum/2QtflFm6xMU – kencorbin Mar 29 '14 at 22:03