0

SMSサービスアプリケーションを構築しました。デバイス(モバイルデバイス)ベースの設定でデフォルト手段を使用したいSMSの受信時に通知を表示したいです。つまり、振動を選択してから振動するか、LEDを選択したNotification.DEFAULT_LIGHTS場合、またはサウンドを選択した場合またはリングしNotification.DEFAULT_SOUNDます。この点で私を助けてください、または私の下手な英語または理解できないことを申し訳ありません. 以下のコードにもタグを付けます

private void displayNotification(String msg)
{
    Intent i = new Intent(this.context,ZigbeeActivity.class);
    i.putExtra("ID", ID);
    i.putExtra("msg",msg);
    PendingIntent pendInt = PendingIntent.getActivity(context, 0, i, 0);
    Notification notif = new Notification(0,"Receiving SMS",System.currentTimeMillis());
    NotificationManager nm = (NotificationManager)context.getSystemService(context.NOTIFICATION_SERVICE);
    notif.setLatestEventInfo(context, "SMS", msg, pendInt);     
    notif.flags = Notification.FLAG_AUTO_CANCEL;
    notif.icon = R.drawable.notify;     
    notif.defaults |= Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND |     Notification.DEFAULT_VIBRATE;          
    notif.ledARGB = Color.WHITE;
    notif.flags |= Notification.FLAG_SHOW_LIGHTS;
    notif.ledOnMS = 1500;                         
    notif.ledOffMS = 1500;      
    nm.notify(ID, notif);
}
4

1 に答える 1