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


Java Ringtone.stop方法代码示例

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


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

示例1: getRingtoneTitle

import android.media.Ringtone; //导入方法依赖的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: onRingtoneSelected

import android.media.Ringtone; //导入方法依赖的package包/类
private void onRingtoneSelected(String uriString) {
    mContactData.ringtoneUri = uriString;
    String buttonText = "No custom ringtone";
    if (SILENT.equals(uriString)) {
        buttonText = "Force silent";
    } else {
        try {
            Uri uri = Uri.parse(uriString);
            if (uri != null && !GLOBAL.equals(uriString)) {
                Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), uri);
                buttonText = ringtone.getTitle(getActivity());
                ringtone.stop();
            }
        } catch (Exception e) {
            Log.e(TAG, "onRingtoneSelected: error", e);
        }
    }
    mChooseRingtoneButton.setText(buttonText);
}
 
开发者ID:andreiciubotariu,项目名称:contact-notifier,代码行数:20,代码来源:ColorVibrateDialog.java

示例3: onActivityResultFragment

import android.media.Ringtone; //导入方法依赖的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

示例4: getSummary

import android.media.Ringtone; //导入方法依赖的package包/类
@Override
public CharSequence getSummary() {
    Uri soundUri = TazSettings.getInstance(getContext()).getNotificationSoundUri(getKey());
    if (soundUri == null) return getContext().getString(R.string.notification_sound_silent);
    else {
        try {
            Ringtone ringtone = RingtoneManager.getRingtone(getContext(), soundUri);
            String title = ringtone.getTitle(getContext());
            ringtone.stop();
            return title;
        } catch (Exception e) {
            return e.getMessage();
        }
    }
}
 
开发者ID:die-tageszeitung,项目名称:tazapp-android,代码行数:16,代码来源:NotificationSoundPreference.java

示例5: process

import android.media.Ringtone; //导入方法依赖的package包/类
public void process(ArrayList suggestedWords){

        Uri callring = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
        Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), callring);

        for (int i = 0; i < suggestedWords.size(); i++) {

            if(suggestedWords.get(i).toString().contains("hello")) {
                Toast.makeText(this, "Hello to you too !", Toast.LENGTH_LONG).show();
            }else if(suggestedWords.get(i).toString().contains(sharedpreferences.getString("helpWord","help"))){

                makeCall();

                //send SMS if it is enabled
                if(Boolean.parseBoolean(sharedpreferences.getString("sendSMSBoolean","true"))) {
                    if(Boolean.parseBoolean(sharedpreferences.getString("sendLocation","true"))) {
                        setSMSContent();
                    }
                    sendSMSMessage();
                }

                //start audio recording if it is enabled
                if(Boolean.parseBoolean(sharedpreferences.getString("recordAudioBoolean", "true"))) {
                    startAudioRecording();
                }

            }else if(suggestedWords.get(i).toString().contains("ring")){
                r.play();
            }else if(suggestedWords.get(i).toString().contains("stop")){
                r.stop();
            }

        }

    }
 
开发者ID:sidbhatt11,项目名称:Emergency_Voice_Android_Application,代码行数:36,代码来源:MainActivity.java

示例6: process

import android.media.Ringtone; //导入方法依赖的package包/类
public void process(ArrayList suggestedWords){

        Log.d("CapturedWord","Got a word");

        Uri callring = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
        Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), callring);

        for (int i = 0; i < suggestedWords.size(); i++) {

            Log.d("CapturedWord", "The word is :" + suggestedWords.get(i).toString());

            if (suggestedWords.get(i).toString().contains("hello")) {
                Toast.makeText(getApplicationContext(), "Hello to you too !", Toast.LENGTH_LONG).show();
            } else if (suggestedWords.get(i).toString().contains(sharedpreferences.getString("helpWord", "help"))) {

                makeCall();

                //send SMS if it is enabled
                if (Boolean.parseBoolean(sharedpreferences.getString("sendSMSBoolean", "true"))) {
                    if(Boolean.parseBoolean(sharedpreferences.getString("sendLocation","true"))) {
                        setSMSContent();
                    }
                    sendSMSMessage();
                }

                //start audio recording if it is enabled
                if (Boolean.parseBoolean(sharedpreferences.getString("recordAudioBoolean", "true"))) {
                    startAudioRecording();
                }

            } else if (suggestedWords.get(i).toString().contains("ring")) {
                r.play();
            } else if (suggestedWords.get(i).toString().contains("stop")) {
                r.stop();
            }

        }//for () over

    }
 
开发者ID:sidbhatt11,项目名称:Emergency_Voice_Android_Application,代码行数:40,代码来源:MyService.java

示例7: stopRingtone

import android.media.Ringtone; //导入方法依赖的package包/类
public static void stopRingtone() {
	if (v != null)
		v.cancel();
	if (Receiver.oRingtone != null) {
		Ringtone ringtone = Receiver.oRingtone;
		oRingtone = null;
		ringtone.stop();
	}
}
 
开发者ID:mnhkahn,项目名称:cInterphone,代码行数:10,代码来源:Receiver.java

示例8: stopRingtone

import android.media.Ringtone; //导入方法依赖的package包/类
public static void stopRingtone() {
	android.os.Vibrator v = (Vibrator) mContext
			.getSystemService(Context.VIBRATOR_SERVICE);
	v.cancel();
	if (oRingtone != null) {
		Ringtone ringtone = oRingtone;
		oRingtone = null;
		ringtone.stop();
	}
}
 
开发者ID:ikantech,项目名称:yiim_v2,代码行数:11,代码来源:CallActivity.java

示例9: beep

import android.media.Ringtone; //导入方法依赖的package包/类
/**
 * 设备播放默认蜂鸣声.
 *
 * @param count
 *            播放 notification 的次数
 */
public void beep(final long count) {
    Uri ringtoneUri = RingtoneManager
            .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone ringtone = RingtoneManager.getRingtone(mCordova.getActivity(), ringtoneUri);

    // 如果设备设置成静音状态,则返回
    if (ringtone == null) {
        return;
    }

    for (long i = 0; i < count; ++i) {
        ringtone.play();
        // timeout是一个经验值,有可能beep的声音超时5s,则需要调用stop来停止播放
        long timeout = 5000;
        while (ringtone.isPlaying() && (timeout > 0)) {
            timeout -= 100;
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            }
        }
        /**
         * 在Android2.1上调用ringtone.play后会一直循环播放,所以在超时过后需要stop
         * 同时,在Android2.2及其以上版本,有可能notification beep的播放时间超过5s,
         * 也需要调用stop接口来结束播放
         */
        ringtone.stop();
    }
}
 
开发者ID:polyvi,项目名称:xface-android,代码行数:36,代码来源:XNotification.java

示例10: beep

import android.media.Ringtone; //导入方法依赖的package包/类
/**
 * 设备播放默认蜂鸣声.
 *
 * @param count
 *            播放 notification 的次数
 */
public void beep(final long count) {
    Uri ringtoneUri = RingtoneManager
            .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone ringtone = RingtoneManager.getRingtone(mSystemContext.getContext(), ringtoneUri);

    // 如果设备设置成静音状态,则返回
    if (ringtone == null) {
        return;
    }

    for (long i = 0; i < count; ++i) {
        ringtone.play();
        // timeout是一个经验值,有可能beep的声音超时5s,则需要调用stop来停止播放
        long timeout = 5000;
        while (ringtone.isPlaying() && (timeout > 0)) {
            timeout -= 100;
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            }
        }
        /**
         * 在Android2.1上调用ringtone.play后会一直循环播放,所以在超时过后需要stop
         * 同时,在Android2.2及其以上版本,有可能notification beep的播放时间超过5s,
         * 也需要调用stop接口来结束播放
         */
        ringtone.stop();
    }
}
 
开发者ID:polyvi,项目名称:openxface-android,代码行数:36,代码来源:XNotification.java

示例11: onActivityResultFragment

import android.media.Ringtone; //导入方法依赖的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:MLNO,项目名称:airgram,代码行数:42,代码来源:NotificationsSettingsActivity.java

示例12: onActivityResultFragment

import android.media.Ringtone; //导入方法依赖的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 (requestCode == callsRingtoneRow) {
                    if (ringtone.equals(Settings.System.DEFAULT_RINGTONE_URI)) {
                        name = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone);
                    } else {
                        name = rng.getTitle(getParentActivity());
                    }
                } else {
                    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");
            }
        } else if (requestCode == callsRingtoneRow) {
            if (name != null && ringtone != null) {
                editor.putString("CallsRingtone", name);
                editor.putString("CallsRingtonePath", ringtone.toString());
            } else {
                editor.putString("CallsRingtone", "NoSound");
                editor.putString("CallsRingtonePath", "NoSound");
            }
        }
        editor.commit();
        adapter.notifyItemChanged(requestCode);
    }
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:58,代码来源:NotificationsSettingsActivity.java

示例13: onActivityResultFragment

import android.media.Ringtone; //导入方法依赖的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 (requestCode == 13) {
                    if (ringtone.equals(Settings.System.DEFAULT_RINGTONE_URI)) {
                        name = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone);
                    } else {
                        name = rng.getTitle(getParentActivity());
                    }
                } else {
                    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");
            }
        } else if (requestCode == 13) {
            if (name != null) {
                editor.putString("ringtone_" + dialog_id, name);
                editor.putString("ringtone_path_" + dialog_id, ringtone.toString());
            } else {
                editor.putString("ringtone_" + dialog_id, "NoSound");
                editor.putString("ringtone_path_" + dialog_id, "NoSound");
            }
        }
        editor.commit();
        if (adapter != null) {
            adapter.notifyItemChanged(requestCode == 13 ? ringtoneRow : soundRow);
        }
    }
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:55,代码来源:ProfileNotificationsActivity.java


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