Question

Trying to make my app to be default SMS app (as it required in KitKat). instructions are pretty clear, instead point:

In a service, include an intent filter for ACTION_RESPONSE_VIA_MESSAGE ("android.intent.action.RESPOND_VIA_MESSAGE") with schemas, sms:, smsto:, mms:, and mmsto:. This service must also require the SEND_RESPOND_VIA_MESSAGE permission.

Can't really understand how to write this Service? I have tried to follow Android sources but it's still unclear.

Anyone can point me to good example how it works?

Was it helpful?

Solution

Example of sms app that register for this intent :

protected void onHandleIntent(Intent intent) {
        if (intent != null) {
            if (TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(intent.getAction())) {
                String num = intent.getDataString();
                num = num.replace("smsto:", "").replace("sms:", "");
                String msg = intent.getStringExtra(Intent.EXTRA_TEXT);
                // send the data to via intent
                Intent intentService = new Intent(this, SomeClass.class);
                startService(intentService);
            }
        }
    }

sending msg via SmsManeger - smsManager.sendTextMessage(address, null, msg, piSent, piDelivered);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top