2011-05-04 4 views
2

안녕하세요. 알림에 대한 설명서를 보았지만 도움이되지 않습니다. 조언을 따라 다음과 같은 클래스에 적용 : 상태 표시 줄 알림과 함께 진동 및/LED를 적용하려고했습니다 (상태 표시 줄 알림이 작동 함). 문서의 조언을 따를 때, 다음을 삽입해야한다고 나와 있습니다 : otification.defaults | = Notification.DEFAULT_VIBRATE; 하지만 알림을 변수로 해석 할 수 없다는 오류가 발생하고 "알림"을 note.notification으로 변경하면 알림이 전혀 표시되지 않습니다. 응용 프로그램 만 실행됩니다. 주석 처리 한 행을 삭제하면됩니다. 내가 어디로 잘못 가고 있는지 확실하지 않습니까? 감사.Android 알림 진동/LED가 작동하지 않습니까?

공용 클래스 ReminderService는 WakeReminderIntentService를 확장 {

public ReminderService() { 
    super("ReminderService"); 
     } 

@Override 
void doReminderWork(Intent intent) { 
    Log.d("ReminderService", "Doing work."); 
    Long rowId = intent.getExtras().getLong(RemindersDbAdapter.KEY_ROWID); 

    NotificationManager mgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); 

    Intent notificationIntent = new Intent(this, ReminderEditActivity.class); 
    notificationIntent.putExtra(RemindersDbAdapter.KEY_ROWID, rowId); 

    PendingIntent pi = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT); 

    Notification note=new Notification(android.R.drawable.stat_sys_warning, getString(R.string.notify_new_task_message), System.currentTimeMillis()); 
    note.setLatestEventInfo(this, getString(R.string.notify_new_task_title), getString(R.string.notify_new_task_message), pi); 
    note.defaults |= Notification.DEFAULT_SOUND; 

// 내가 문제

정확히 통지를 정의 할
**notification.defaults |= Notification.DEFAULT_VIBRATE; 
    notification.ledARGB = 0xff00ff00; 
    notification.ledOnMS = 300; 
    notification.ledOffMS = 1000; 
    notification.flags |= Notification.FLAG_SHOW_LIGHTS;** 
    note.flags |= Notification.FLAG_AUTO_CANCEL; 

답변

0

하는 데 문제가있는 곳은? Notification 인스턴스가 노트 객체이므로 알림이 정의되지 않습니다.

문제를 해결하려면 모든 알림 참조를 메모로 바꿉니다.

+0

안녕하세요. 나는이 모든 것을 테스트 노트로 대체했습니다. 애플리케이션을 실행할 때 정렬에 대한 알림이 표시되지 않았습니다. – Superunknown

+0

통지를 NotificationManager로 올바르게 전달했는지 확인 했습니까? – Moystard

+0

그런데 Notification 생성자가 사용되지 않으므로 Notification.Builder를 사용해야합니다. [Notification API Reference] (http://developer.android.com/reference/android/app/Notification.html) – Moystard

관련 문제