2012-01-24 5 views
2

私は、notification.wavファイルを含む生のフォルダを使用しています。通知が電話に入ると、それは健全なnotification.wavファイルのアラートになります。音通知

私はこのコードを使用しています:

Uri path = Uri.parse("android.resource://" + getPackageName() + "/notification.wav"); 
notification.sound = path; 

助けてください。

+0

あなたが直面しているエラーをよ何誤りますか?通知を再生できませんか?または一部のデバイスでのみ再生されていませんか? – GoodSp33d

+0

デバイスで再生されていません –

答えて

0
MediaPlayer mMediaPlayer = new MediaPlayer(); 
mMediaPlayer = MediaPlayer.create(this, R.raw.alpha); 
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); 
mMediaPlayer.setLooping(true); 
mMediaPlayer.start(); 
1
String ns = Context.NOTIFICATION_SERVICE; 
     NotificationManager notificationManager = (NotificationManager) getSystemService(ns); 
     int icon = R.drawable.update; 
     CharSequence tickerText = "assignments"; 
     long when = System.currentTimeMillis(); 

     Notification assignmentNotification = new Notification(icon, tickerText, when); 
     **For sound** assignmentNotification.defaults |= Notification.DEFAULT_SOUND; 
     long[] vibrate = {0,100,200,300}; 
     **For vibrate** assignmentNotification.vibrate = vibrate; 
     Context context = getApplicationContext(); 
     CharSequence contentTitle = "check assignments"; 
     CharSequence contentText = "chek ur app for assignments "; 
     Intent notificationIntent = new Intent(context, ViewAssignmentnotificationActivity.class); 
     PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent,0); 
     assignmentNotification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); 
     ** final int id = 2; 
関連する問題