3

嗨,大家好我是新來的Android和設計的同時我的應用我有一個問題..當通知欄拖到

我設計了一個報警服務的應用程序在該應用中,每當警報啓動時,它會在通知欄和顯示問題是,我想停下來報警和通知每當我拖動通知欄我用Google搜索了很多,但沒能得到它你的想法會幫助我很多 這裏是我的代碼

if(pYear==pYear2 && pMonth==pMonth2 && pDay==pDay2 && pHour==pHour2 && pMin==pMin2 && pSec==psec2) 
{ 

Context context = getApplicationContext(); 

Intent notifyIntent = new Intent(context, MyAlarmService.class); 

PendingIntent intent1 =PendingIntent.getActivity(MyAlarmService.this, 0, notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK); 

Notification notifyDetails = new Notification(R.drawable.ic_launcher,"New Alert, Click Me!",System.currentTimeMillis()); 

notifyDetails.setLatestEventInfo(context, "Alaram", "Get back to Application on clicking me", intent1); 

mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails); 

AudioManager am=(AudioManager)getSystemService(Context.AUDIO_SERVICE); 

am.setMode(AudioManager.MODE_NORMAL); 

try 
{ 
    mp.setDataSource(getApplicationContext(), ringtoneUri); 
    mp.setAudioStreamType(AudioManager.STREAM_NOTIFICATION); 
    mp.prepare(); 
    mp.setLooping(true); 
    mp.start(); 
} 
catch(Exception e) 
{ 
    //exception caught in the end zone 
} 
+0

檢查此.. http://developer.android.com/reference/android/view/View.OnSystemUiVisibilityChangeListener.html – ngesh 2013-03-06 10:38:12

+0

thnq但它與我的問題沒有關係 – Ramya 2013-03-06 11:14:36

回答

1

播放通知聲音,你應該使用 notifyDetails.defaults | = Notification.DEFAULT_SOUND;