當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。