拖动通知栏时

时间:2013-03-06 10:31:29

标签: android notifications android-notifications android-notification-bar

大家好我是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
}

1 个答案:

答案 0 :(得分:1)

播放您应该使用的通知声音 notifyDetails.defaults | = Notification.DEFAULT_SOUND;