Android 4.4 has an update, and the text message mechanism change is a major event in the update.
How can I make the text message application apply to a blog on the official website of 4.4 that has been translated and reprinted N times? I will post a link to it. 4.4 text message application changes
Here I am not going to explain how to set up the text message application. The following is a small demand, it is how to switch the default text message application to another application in your own application (or let the user select the default text message application in your own app, you don't have to go to "more than" in the settings to find the things and choose again)
The idea of setting the default SMS application is to get the information of the application that meets the requirements -- get the package name of these applications -- set the default SMS application according to the package name
The first two steps are the key, and the third step can refer to the above 4.4 SMS application changes
This method is not perfect. You can perform further screening based on the features of 4.4 default SMS.
The Code is as follows:
/*** Get the default SMS application package name array * @ return */private String [] getSmsApps () {PackageManager pm = this. getPackageManager (); Intent intent = new Intent (); intent. setAction ("android. provider. telephony. SMS_DELIVER "); List
Receivers = pm. queryBroadcastReceivers (intent, PackageManager. GET_INTENT_FILTERS); String [] result = new String [receivers. size ()]; for (int I = 0; I <receivers. size (); I ++) {result [I] = receivers. get (I ). activityInfo. packageName;} return result ;}