I'm creating an SMS message inside Inbox folder as follows:
ContentValues values = new ContentValues();
values.put("address", sender);
values.put("date", System.currentTimeMillis());
values.put("read", 0); // Message not read
values.put("status", 0);
values.put("type", 1);
values.put("seen", 0);
values.put("body", body);
ContentResolver rslv = context.getContentResolver();
rslv.insert(Uri.parse("content://sms"), values);
This works well, but doesn't fire the usual "SMS received" notification in the top bar and play the notfitication sound. How do I do write such notification code (which presumably calls some SMS application's Intent to raise the notification) ?
Building a notification is done by using Notification.Builder
class. A really simple example is this:
Notification noti = new Notification.Builder(mContext)
.setContentTitle("New SMS from " + sender.toString())
.setContentText(subject)
.setSmallIcon(R.drawable.new_mail)
.setLargeIcon(aBitmap)
.build();
More information is available in the official tutorial for the same.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.