Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;

public class Main {
    /**
     * Getter for the current Default Notification Ringtone object.
     * @param ctx
     * @return The Ringtone, or null if there isn't one set.
     */
    public static Ringtone getDefaultNotificationRingtone(Context ctx) {
        Uri currentNotificationRingtoneUri = getDefaultNotificationRingtoneUri(ctx);

        if (currentNotificationRingtoneUri == null) {
            return null;
        }

        Ringtone r = RingtoneManager.getRingtone(ctx, currentNotificationRingtoneUri);

        return r;
    }

    /**
     * Getter for the current Default Notification Ringtone URI.
     * @param ctx
     * @return
     */
    public static Uri getDefaultNotificationRingtoneUri(Context ctx) {
        return RingtoneManager.getActualDefaultRingtoneUri(ctx, RingtoneManager.TYPE_NOTIFICATION);
    }
}