Pergunta

I've found not exactly clear place in the SmsManager documentation.

Class SmsManager, method sendTextMessage, parameter sentIntent (http://developer.android.com/reference/android/telephony/SmsManager.html):

The per-application based SMS control checks sentIntent. If 
sentIntent is NULL the caller will be checked against all 
unknown applications, which cause smaller number of SMS to 
be sent in checking period.

What does it mean? What control will be performed? Who (what component) does it perform? What is known and unknown applications? What may be the result of checking?

Foi útil?

Solução

This text refers to sentIntent. In android OS, apps have some reasonable limits for sending SMS without user permission asked every time. If these limits are exceeded a dialog for send SMS permission is presented to the user. Limits are counted normally per application, but if you don't set the sentIntent then there's no way for the SmsUsageMonitor class to know from which app the send SMS request is coming so it will count your app limit along with other apps that don't set the sentIntent and the limit will be smaller. As a result it's best to provide a sentIntent, even if it's a dummy one.

Outras dicas

There are limits and restrictions on how many SMS's can an app send in a given period of time. It is implemented in SmsUsageMonitor (at least in Android 4.x).

For example, take a look at SmsUsageMonitor.check(String appName, int smsWaiting):

 public boolean More ...check(String appName, int smsWaiting) {
     /* ... */ 
     return isUnderLimit(sentList, smsWaiting);
 }

As you can see, there is a list of SMS's send by an app. isUnderLimit() simply checks if this list is no longer than a limit.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top