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?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top