2013-03-26 8 views
-4

안드로이드에서 특정 시간 동안 알람 알림을 재생하려면 어떻게해야합니까? (예 : 10 분 연속)?10 분 동안 알람 알림을 재생하는 방법

public class AlarmReciver extends BroadcastReceiver{ 

private static int NOTIFICATION_ID = 1; 
Bundle bundle; 
int notificationId = 0; 
AudioManager audioManager; 
@Override 
public void onReceive(Context context, Intent intent) { 
// TODO Auto-generated method stub 
    try{ 
    audioManager = (AudioManager) context.getSystemService (Context.AUDIO_SERVICE); 
    audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); 
    int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); 
    audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, maxVolume, 0); 
     //audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0); 
    notificationId = intent.getExtras().getInt("notificationId"); 
    NotificationManager manger = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
Notification notification = new Notification(R.drawable.ic_launcher, "YourBestSelfApp", System.currentTimeMillis()); 
notification.flags |= Notification.FLAG_AUTO_CANCEL; 
notification.defaults = Notification.DEFAULT_VIBRATE|Notification.DEFAULT_LIGHTS; 
notification.sound = Uri.parse("android.resource://"+context.getPackageName()+"/"+R.raw.iphone_5_original); 
Intent intent1 = new Intent(context,WelcomeActivity.class); 
intent1.putExtra("activityFrom", "notificationAlarm"); 
PendingIntent activity = PendingIntent.getActivity(context,NOTIFICATION_ID + 1, intent1, PendingIntent.FLAG_UPDATE_CURRENT); 
notification.setLatestEventInfo(context, "hello","", activity); 
notification.number = 1; 
manger.notify(notificationId, notification); 
    }catch (Exception e) { 
    // TODO: handle exception 
    e.printStackTrace(); 
      } 
     } 
+1

[Welcome to Stackoverflow] – RobinHood

+0

무엇이 실제로 질문입니까 ??? – Gunaseelan

답변

0

// 연락 SyncBroadcast.class, 그것은

Intent intent = new Intent(this,ContactsSyncBroadcast.class); 
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 
       0, intent, PendingIntent.FLAG_UPDATE_CURRENT); 
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE); 
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,10*60*1000,10*60*1000, pendingIntent); 

경보가 매 10 분 동안 트리거 활동 또는 광범위한 캐스트 수신기 또는 서비스를 할 수 있습니다.

+0

나는 10 분마다 알람을 반복하지 않고 알람 링 지속 시간을 설정하고 싶습니다. – user2099162