Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;

import android.media.RingtoneManager;
import android.net.Uri;

public class Main {
    public static void playRingtone(Context context) {
        //       Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        //        if(alert == null){
        //            alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
        //        }
        //       Ringtone r = RingtoneManager.getRingtone(context, alert);
        //       r.play();

        Uri path = Uri.parse("android.resource://" + context.getPackageName() + "/raw/waterdrop4");
        //       RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE,path);
        RingtoneManager.getRingtone(context, path).play();
    }
}