Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 合理通知_Android - Fatal编程技术网

Android 合理通知

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

我正在使用原始文件夹contain notification.wav文件。当手机收到通知时,它会提醒您注意sound 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;