Android 合理通知
我正在使用原始文件夹contain notification.wav文件。当手机收到通知时,它会提醒您注意sound notification.wav文件 我正在使用以下代码:Android 合理通知,android,Android,我正在使用原始文件夹contain notification.wav文件。当手机收到通知时,它会提醒您注意sound notification.wav文件 我正在使用以下代码: Uri path = Uri.parse("android.resource://" + getPackageName() + "/notification.wav"); notification.sound = path; 请帮助。错误您面临的错误是什么?您不能播放通知吗?或者它不只是在某些设备上播放? MediaP
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;