17
Tôi có trình quản lý báo thức khởi động bộ thu phát sóng. Đây là thu phát sóng của tôi:Android: thông báo từ BroadcastReceiver
public class AlarmBrodcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent arg1) {
showNotification(context);
}
private void showNotification(Context context) {
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
new Intent(context, MyActivity.class), 0);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(0)
.setContentTitle("My notification")
.setContentText("Hello World!");
mBuilder.setContentIntent(contentIntent);
mBuilder.setDefaults(Notification.DEFAULT_SOUND);
mBuilder.setAutoCancel(true);
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());
}
}
dung phát bắt đầu trong thời gian, nhưng không có thông báo, chỉ âm thanh. Văn bản ở đâu? Chuyện gì vậy? Có phải vì tôi đang sử dụng API 10 và thư viện hỗ trợ không?
Tôi không có vấn đề cụ thể của bạn, nhưng nhờ bạn, tôi đã đảm bảo rằng có thể làm ở cấp API của tôi. – ravemir