0

通知メッセージにデータベースの内容(2語のみ)を表示しようとしていますが、タイトルだけが表示されるのはなぜですか?2番目の問題:AlarmManagerを使用して1分ごとにintentserviceクラス(このコードを含むクラス)をトリガーしましたが、data == nullの場合、発生してはならない状態で通知されます

 ShowTimeDB RetrieverDB =new ShowTimeDB(this);
    RetrieverDB.open();
    String data = RetrieverDB.getShowNotify();
    RetrieverDB.close();

    if (data!=null){

        nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);




        Intent intent=new Intent(this,TodayShow.class);
        PendingIntent pi= PendingIntent.getActivity(this, 0, intent, 0);
        CharSequence x=(CharSequence) data;
        Notification n=new Notification(R.drawable.ic_launcher,"YOU HAVE SHOw" ,System.currentTimeMillis());
        n.setLatestEventInfo(this, "ShowTime", x, pi);
        n.defaults=Notification.DEFAULT_ALL;

        nm.notify(uniqueID,n);
4

1 に答える 1

0

Notificationの代わりにNotification.Builderを使用してみてください。新しいNotification()を使用したNotificationオブジェクトの構築は廃止され、Notification.Builderクラスを使用するようになりました。THereは、1.6までのバージョンとの互換性のためのNotificationCompat.Builderでもあります。

2番目の質問の意味がわかりません。

于 2013-03-26T18:53:41.250 に答える