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?

Était-ce utile?

La 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);

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top