当前位置: 首页>>代码示例>>Java>>正文


Java RingtoneManager.getRingtone方法代码示例

本文整理汇总了Java中android.media.RingtoneManager.getRingtone方法的典型用法代码示例。如果您正苦于以下问题:Java RingtoneManager.getRingtone方法的具体用法?Java RingtoneManager.getRingtone怎么用?Java RingtoneManager.getRingtone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.media.RingtoneManager的用法示例。


在下文中一共展示了RingtoneManager.getRingtone方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRingtoneTitle

import android.media.RingtoneManager; //导入方法依赖的package包/类
private String getRingtoneTitle() {
    DebugLog.logMethod();
    String ringtoneUri = getPreferenceManager().getSharedPreferences().getString(
            KEY_NOTIFICATION_RINGTONE,
            RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION).toString()
    );
    Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), Uri.parse(ringtoneUri));
    String ringtoneTitle = ringtone.getTitle(getActivity());
    // Prevent memory leaks
    ringtone.stop();

    return ringtoneTitle;
}
 
开发者ID:darsh2,项目名称:CouponsTracker,代码行数:14,代码来源:SettingsFragment.java

示例2: getRingtoneName

import android.media.RingtoneManager; //导入方法依赖的package包/类
/**
 * Get the title of the ringtone from the uri of ringtone.
 *
 * @param context instance of the caller
 * @param uri     uri of the tone to search
 * @return title of the tone or return null if no tone found.
 */
@Nullable
public static String getRingtoneName(@NonNull Context context,
                                     @NonNull Uri uri) {
    Ringtone ringtone = RingtoneManager.getRingtone(context, uri);
    if (ringtone != null) {
        return ringtone.getTitle(context);
    } else {
        Cursor cur = context
                .getContentResolver()
                .query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                        new String[]{MediaStore.Audio.Media.TITLE},
                        MediaStore.Audio.Media._ID + " =?",
                        new String[]{uri.getLastPathSegment()},
                        null);

        String title = null;
        if (cur != null) {
            title = cur.getString(cur.getColumnIndex(MediaStore.Audio.Media.TITLE));
            cur.close();
        }
        return title;
    }
}
 
开发者ID:kevalpatel2106,项目名称:android-ringtone-picker,代码行数:31,代码来源:RingtoneUtils.java

示例3: initSeekBar

import android.media.RingtoneManager; //导入方法依赖的package包/类
private void initSeekBar(SeekBar seekBar, Uri defaultUri) {
    seekBar.setMax(mAudioManager.getStreamMaxVolume(mStreamType));
    mOriginalStreamVolume = mAudioManager.getStreamVolume(mStreamType);
    seekBar.setProgress(mOriginalStreamVolume);
    seekBar.setOnSeekBarChangeListener(this);
    // TODO: removed in MM, find different approach
    mContext.getContentResolver().registerContentObserver(
            System.getUriFor("volume_ring"),
            false, mVolumeObserver);
    if (defaultUri == null) {
        if (mStreamType == AudioManager.STREAM_RING) {
            defaultUri = Settings.System.DEFAULT_RINGTONE_URI;
        } else if (mStreamType == AudioManager.STREAM_NOTIFICATION) {
            defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
        } else {
            defaultUri = Settings.System.DEFAULT_ALARM_ALERT_URI;
        }
    }
    mRingtone = RingtoneManager.getRingtone(mContext, defaultUri);
    if (mRingtone != null) {
        mRingtone.setStreamType(mStreamType);
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:24,代码来源:VolumePreference.java

示例4: onInitSample

import android.media.RingtoneManager; //导入方法依赖的package包/类
private void onInitSample() {
    mRingtone = RingtoneManager.getRingtone(getContext(),
            Settings.System.DEFAULT_RINGTONE_URI);
    if (mRingtone != null) {
        mRingtone.setStreamType(AudioManager.STREAM_RING);
        mRingtone.setAudioAttributes(
                new AudioAttributes.Builder(mRingtone.getAudioAttributes())
                        .setFlags(AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY |
                                AudioAttributes.FLAG_BYPASS_MUTE)
                        .build());
    }
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:13,代码来源:IncreasingRingVolumePreference.java

示例5: createNotif

import android.media.RingtoneManager; //导入方法依赖的package包/类
public void createNotif() {
    Intent intent = new Intent(context, MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    String eventName = eventsForNotif[0];
    if (counterForCurrentEventsForNotif > 1) {
        for (int i = 1; i < counterForEventsForNotif; i++) {
            if (i == counterForCurrentEventsForNotif - 1)
                eventName = eventName + " and " + currentEventsForNotif[i];
            else
                eventName = eventName + ", " + currentEventsForNotif[i];
        }
    }

    Uri notifRing = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone ringtone =RingtoneManager.getRingtone(context, notifRing);
    ringtone.play();
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(500);

    Log.d("alarm","ture");
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_calendar)
            .setContentTitle("Trinity")
            .setAutoCancel(true)
            .setContentIntent(pendingIntent)
            .setContentText(eventName + " scheduled for today.");
    NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    int mNotifId = 1;
    manager.notify(mNotifId, builder.build());
}
 
开发者ID:Ronak-59,项目名称:Trinity-App,代码行数:31,代码来源:NotifAlarmReceiver.java

示例6: getSoundName

import android.media.RingtoneManager; //导入方法依赖的package包/类
public String getSoundName(Context context) {
	if (sound == null) {
		return context.getString(R.string.notification_options_off);
	}
	Uri uri = Uri.parse(sound);
	if (Settings.System.DEFAULT_NOTIFICATION_URI.equals(uri)) {
		return context.getString(R.string.notification_options_default);
	}
	Ringtone ringtone = RingtoneManager.getRingtone(context, uri);
	return ringtone != null ? ringtone.getTitle(context) : context.getString(R.string.notification_options_off);
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:12,代码来源:NotificationOptions.java

示例7: notifyNewMensage

import android.media.RingtoneManager; //导入方法依赖的package包/类
private void notifyNewMensage(Chat chat){
    notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);

    Intent intent = new Intent(getActivity(), ChatActivity.class);
    intent.putExtra("name",chat.getName());
    intent.putExtra("email", Base64Custom.decodeBase64(chat.getUserId()));

    PendingIntent pendingIntent = PendingIntent.getActivity(getContext(),0, intent,0);

    NotificationCompat.Builder builder = new android.support.v7.app.NotificationCompat.Builder(getContext());
    builder.setContentIntent(pendingIntent);
    builder.setTicker("Nova mensagem de "+chat.getName());
    builder.setContentTitle("Mensagem de "+chat.getName());
    builder.setContentText(chat.getMensageValue());
    builder.setSmallIcon(R.drawable.ic_chat);
    builder.setVibrate(new long[] { 200, 200, 200, 200, 200 });

    Notification notification = builder.build();
    notificationManager.notify(Integer.parseInt(chat.getUserId().replaceAll("[^0-9]", "")), notification);

    try{
        Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        Ringtone ringtone = RingtoneManager.getRingtone(getContext(),uri);
        ringtone.play();
    }catch (Exception e){

    }
}
 
开发者ID:VitorPoncell,项目名称:poturnoChat,代码行数:29,代码来源:ChatFragment.java

示例8: onActivityResultFragment

import android.media.RingtoneManager; //导入方法依赖的package包/类
@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        if (data == null) {
            return;
        }
        Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
        String name = null;
        if (ringtone != null) {
            Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone);
            if (rng != null) {
                if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
                    name = LocaleController.getString("SoundDefault", R.string.SoundDefault);
                } else {
                    name = rng.getTitle(getParentActivity());
                }
                rng.stop();
            }
        }

        SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();

        if (requestCode == 12) {
            if (name != null) {
                editor.putString("sound_" + dialog_id, name);
                editor.putString("sound_path_" + dialog_id, ringtone.toString());
            } else {
                editor.putString("sound_" + dialog_id, "NoSound");
                editor.putString("sound_path_" + dialog_id, "NoSound");
            }
        }
        editor.commit();
        listView.invalidateViews();
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:37,代码来源:ProfileNotificationsActivity.java

示例9: onCreate

import android.media.RingtoneManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.other_sound_settings);

    mContext = getActivity();

    // power state change notification sounds
    mPowerSoundsVibrate = (SwitchPreference) findPreference(KEY_POWER_NOTIFICATIONS_VIBRATE);
    mPowerSoundsVibrate.setChecked(CMSettings.Global.getInt(getContentResolver(),
            CMSettings.Global.POWER_NOTIFICATIONS_VIBRATE, 0) != 0);
    Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    if (vibrator == null || !vibrator.hasVibrator()) {
        removePreference(KEY_POWER_NOTIFICATIONS_VIBRATE);
    }

    mPowerSoundsRingtone = findPreference(KEY_POWER_NOTIFICATIONS_RINGTONE);
    String currentPowerRingtonePath = CMSettings.Global.getString(getContentResolver(),
            CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE);

    // set to default notification if we don't yet have one
    if (currentPowerRingtonePath == null) {
            currentPowerRingtonePath = System.DEFAULT_NOTIFICATION_URI.toString();
        CMSettings.Global.putString(getContentResolver(),
                CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE, currentPowerRingtonePath);
    }
    // is it silent ?
    if (currentPowerRingtonePath.equals(POWER_NOTIFICATIONS_SILENT_URI)) {
        mPowerSoundsRingtone.setSummary(
                getString(R.string.power_notifications_ringtone_silent));
    } else {
        final Ringtone ringtone =
                RingtoneManager.getRingtone(getActivity(), Uri.parse(currentPowerRingtonePath));
        if (ringtone != null) {
            mPowerSoundsRingtone.setSummary(ringtone.getTitle(getActivity()));
        }
    }

    for (SettingPref pref : PREFS) {
        pref.init(this);
    }
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:44,代码来源:OtherSoundSettings.java

示例10: SinchAudioCall

import android.media.RingtoneManager; //导入方法依赖的package包/类
public SinchAudioCall(Context context)
{
    callClient = ConfigureSinch.retrieveSinchClient().getCallClient();
    mUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
    mRingtone = RingtoneManager.getRingtone(context, mUri);
}
 
开发者ID:parita-detroja,项目名称:cordova-plugin-sinch-calling,代码行数:7,代码来源:SinchAudioCall.java

示例11: onPreferenceChange

import android.media.RingtoneManager; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);
        String title = index >= 0 ? String.valueOf(listPreference.getEntries()[index]) : "";
        //Exibir o tempo total de funcionamento do registrador depois do ultimo reset.
        if (OhaEnergyUseSyncHelper.ENERGY_USE_SYNC_OFTEN_LOGGER_RESET.equals(preference.getKey())){
            Context context = preference.getContext();
            long durationLoggerRunning = preference.getSharedPreferences().getLong(OhaEnergyUseSyncHelper.ENERGY_USE_SYNC_DURATION_LOGGER_RUNNING,0);
            preference.setTitle(String.format(context.getString(R.string.pref_title_energy_use_sync_often_logger_reset), title));
            preference.setSummary(String.format(context.getString(R.string.pref_summary_energy_use_sync_often_logger_reset), OhaHelper.convertMillisToHours(durationLoggerRunning)));

        } else {
            // Set the summary to reflect the new value.
            preference.setSummary(title);
        }

    } else if (preference instanceof RingtonePreference) {
        // For ringtone preferences, look up the correct display value
        // using RingtoneManager.
        if (!TextUtils.isEmpty(stringValue)) {
            Ringtone ringtone = RingtoneManager.getRingtone(
                    preference.getContext(), Uri.parse(stringValue));

            if (ringtone == null) {
                // Clear the summary if there was a lookup error.
                preference.setSummary(null);
            } else {
                // Set the summary to reflect the new ringtone display
                // name.
                String name = ringtone.getTitle(preference.getContext());
                preference.setSummary(name);
            }
        }

    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
开发者ID:brolam,项目名称:OpenHomeAnalysis,代码行数:48,代码来源:AppCompatPreferenceHelper.java

示例12: onPreferenceChange

import android.media.RingtoneManager; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);

    } else if (preference instanceof RingtonePreference) {
        // For ringtone preferences, look up the correct display value
        // using RingtoneManager.
        if (TextUtils.isEmpty(stringValue)) {
            // Empty values correspond to 'silent' (no ringtone).
            preference.setSummary(R.string.pref_ringtone_silent);

        } else {
            Ringtone ringtone = RingtoneManager.getRingtone(
                    preference.getContext(), Uri.parse(stringValue));

            if (ringtone == null) {
                // Clear the summary if there was a lookup error.
                preference.setSummary(null);
            } else {
                // Set the summary to reflect the new ringtone display
                // name.
                String name = ringtone.getTitle(preference.getContext());
                preference.setSummary(name);
            }
        }

    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
开发者ID:akashdeepsingh9988,项目名称:Cybernet-VPN,代码行数:46,代码来源:SettingsActivity.java

示例13: onActivityResultFragment

import android.media.RingtoneManager; //导入方法依赖的package包/类
@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
        String name = null;
        if (ringtone != null) {
            Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone);
            if (rng != null) {
                if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
                    name = LocaleController.getString("SoundDefault", R.string.SoundDefault);
                } else {
                    name = rng.getTitle(getParentActivity());
                }
                rng.stop();
            }
        }

        SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();

        if (requestCode == messageSoundRow) {
            if (name != null && ringtone != null) {
                editor.putString("GlobalSound", name);
                editor.putString("GlobalSoundPath", ringtone.toString());
            } else {
                editor.putString("GlobalSound", "NoSound");
                editor.putString("GlobalSoundPath", "NoSound");
            }
        } else if (requestCode == groupSoundRow) {
            if (name != null && ringtone != null) {
                editor.putString("GroupSound", name);
                editor.putString("GroupSoundPath", ringtone.toString());
            } else {
                editor.putString("GroupSound", "NoSound");
                editor.putString("GroupSoundPath", "NoSound");
            }
        }
        editor.commit();
        listView.invalidateViews();
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:42,代码来源:NotificationsSettingsActivity.java

示例14: onSuccess

import android.media.RingtoneManager; //导入方法依赖的package包/类
@Override
    public void onSuccess(AppApi.Action method, Object obj) {
        super.onSuccess(method, obj);
        switch (method) {
            case POST_IMAGE_PROJECTION_JSON:
                dismissProLoadingDialog();

                if(obj instanceof ImageProResonse) {
                    ImageProResonse proResonseInfo = (ImageProResonse) obj;
                    mProjectId = proResonseInfo.getProjectId();
                    ProjectionManager.getInstance().setProjectId(mProjectId);
                }
                if (small==1){
                    small = 0;
                    switch (mCurrentProType) {
                        case TYPE_PRO_SINGLE:
                            ProjectionManager.getInstance().setSlideStatus(false);
                            if(mProjectionService!=null) {
                                mProjectionService.stopQuerySeek();
                                mProjectionService.stopSlide();
                            }
                            compressFirstImage(mSingleInfo);
                            break;
                        case TYPE_PRO_SLIDES:
                            if(mProjectionService!=null) {
                                mProjectionService.stopQuerySeek();
                                mProjectionService.stopSlide();
                            }
                            if(mSelectedList.size()>0) {
                                compressFirstImage(mSelectedList.get(0));
                            }
                            break;

                    }
                    handleProSuccess();
                    return;
                }
                break;
            case POST_LOCAL_VIDEO_PRO_JSON:
                dismissProLoadingDialog();
                mLoadingDialog.dismiss();
                if(obj instanceof LocalVideoProPesponse) {
                    LocalVideoProPesponse response = (LocalVideoProPesponse) obj;
                    projectId = response.getProjectId();
                    ProjectionManager.getInstance().setProjectId(projectId);
//                    prepareSuccess(prepareResponseVo);
                    Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                    Ringtone r = RingtoneManager.getRingtone(SavorApplication.getInstance(), notification);
                    r.play();

                    dismissLoadingDialog();

                    LocalVideoProAcitvity.startLocalVideoProActivity(this,mCurrentVideoInfo,true,projectId);
                    resetNormalState();
                    if(mProjectionService!=null) {
                        mProjectionService.stopSlide();
                    }
                    ProjectionManager.getInstance().setSlideStatus(false);
                }

                break;

        }
    }
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:65,代码来源:MediaGalleryActivity.java


注:本文中的android.media.RingtoneManager.getRingtone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。