Amit
Amit

Reputation: 225

Kitkat Behaviour: SMS Broadcast Receiver not working after fresh installation and if app is not launched

I have an Android app that listens to SMS messages. This is in the manifest:

<receiver android:name=".SMSListner" >
 <intent-filter>
   <action android:name="android.provider.Telephony.SMS_RECEIVED" />
 </intent-filter>
</receiver>

The broadcast receivers works fine if the app is installed and opened(For all android versions).

When I send a SMS, non Kitkat device(GB version) receives the sms but Kitkat version doesnot.

OnRecieve code is:

public void onReceive( Context context, Intent intent )
{

    String action = intent.getAction();
    Log.v( "KK TEST APP", "===============SMS Received===============" );
    if ( action.equals( ACTION_SMS_RECEIVED ) )
    {
        Log.v( "KK TEST APP", "action.equals( ACTION_SMS_RECEIVED )" );
    }
    else
    {
        Log.v( "KK TEST APP", "other message" );
    }

}

Upvotes: 1

Views: 983

Answers (2)

josego990
josego990

Reputation: 1

You can create a service to call a broadcast receiver. Also, in onCreate method in main activity call this service and this should remain active although your app is killed. Regrads

Upvotes: 0

David C Adams
David C Adams

Reputation: 1973

Apps will not receive broadcasts until they have been launched the first time. This is Android security. They used to be able to, but Google has changed this behavior somewhat recently.

Upvotes: 1

Related Questions