2
我使用的是包含notification.wav文件的原始文件夾。當通知進入手機時,它會提示聲音notification.wav文件。聲音通知
我使用這個代碼:
Uri path = Uri.parse("android.resource://" + getPackageName() + "/notification.wav");
notification.sound = path;
請幫助。
我使用的是包含notification.wav文件的原始文件夾。當通知進入手機時,它會提示聲音notification.wav文件。聲音通知
我使用這個代碼:
Uri path = Uri.parse("android.resource://" + getPackageName() + "/notification.wav");
notification.sound = path;
請幫助。
MediaPlayer mMediaPlayer = new MediaPlayer();
mMediaPlayer = MediaPlayer.create(this, R.raw.alpha);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setLooping(true);
mMediaPlayer.start();
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;
ERR什麼是你所面對的錯誤?你無法播放通知嗎?還是隻在某些設備上播放? – GoodSp33d
它不在設備中播放 –