List of usage examples for android.media MediaPlayer setDataSource
@UnsupportedAppUsage public void setDataSource(String path, Map<String, String> headers) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException
From source file:com.lithiumli.fiction.PlaybackService.java
public void play(int index) { mQueue.setCurrent(index);//w ww . j a va2 s . c o m Song song = mQueue.getCurrent(); Intent intent = new Intent(EVENT_PLAYING); intent.putExtra(DATA_SONG, song); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); broadcastPlayState(PlayState.PLAYING); Log.d("fiction", "Playing new song"); try { MediaPlayer nextMediaPlayer = new MediaPlayer(); nextMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); nextMediaPlayer.setDataSource(getApplicationContext(), song.getUri()); nextMediaPlayer.setOnPreparedListener(this); nextMediaPlayer.prepareAsync(); } catch (IOException e) { } }
From source file:org.yuttadhammo.BodhiTimer.TimerReceiver.java
@Override public void onReceive(Context context, Intent pintent) { Log.v(TAG, "ALARM: received alarm"); NotificationManager mNM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (player != null) { Log.v(TAG, "Releasing media player..."); try {//from ww w .j a va 2s .co m player.release(); player = null; } catch (Exception e) { e.printStackTrace(); player = null; } finally { // do nothing } } // Cancel notification and return... if (CANCEL_NOTIFICATION.equals(pintent.getAction())) { Log.v(TAG, "Cancelling notification..."); mNM.cancelAll(); return; } // ...or display a new one Log.v(TAG, "Showing notification..."); player = new MediaPlayer(); int setTime = pintent.getIntExtra("SetTime", 0); String setTimeStr = TimerUtils.time2humanStr(context, setTime); Log.v(TAG, "Time: " + setTime); CharSequence text = context.getText(R.string.Notification); CharSequence textLatest = String.format(context.getString(R.string.timer_for_x), setTimeStr); // Load the settings SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean led = prefs.getBoolean("LED", true); boolean vibrate = prefs.getBoolean("Vibrate", true); String notificationUri = ""; boolean useAdvTime = prefs.getBoolean("useAdvTime", false); String advTimeString = prefs.getString("advTimeString", ""); String[] advTime = null; int advTimeIndex = 1; if (useAdvTime && advTimeString.length() > 0) { advTime = advTimeString.split("\\^"); advTimeIndex = prefs.getInt("advTimeIndex", 1); String[] thisAdvTime = advTime[advTimeIndex - 1].split("#"); // will be of format timeInMs#pathToSound if (thisAdvTime.length == 3) notificationUri = thisAdvTime[1]; if (notificationUri.equals("sys_def")) notificationUri = prefs.getString("NotificationUri", "android.resource://org.yuttadhammo.BodhiTimer/" + R.raw.bell); } else notificationUri = prefs.getString("NotificationUri", "android.resource://org.yuttadhammo.BodhiTimer/" + R.raw.bell); Log.v(TAG, "notification uri: " + notificationUri); if (notificationUri.equals("system")) notificationUri = prefs.getString("SystemUri", ""); else if (notificationUri.equals("file")) notificationUri = prefs.getString("FileUri", ""); else if (notificationUri.equals("tts")) { notificationUri = ""; final String ttsString = prefs.getString("tts_string", context.getString(R.string.timer_done)); Intent ttsIntent = new Intent(context, TTSService.class); ttsIntent.putExtra("spoken_text", ttsString); context.startService(ttsIntent); } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context.getApplicationContext()) .setSmallIcon(R.drawable.notification).setContentTitle(text).setContentText(textLatest); Uri uri = null; // Play a sound! if (!notificationUri.equals("")) uri = Uri.parse(notificationUri); // Vibrate if (vibrate && uri == null) { mBuilder.setDefaults(Notification.DEFAULT_VIBRATE); } // Have a light if (led) { mBuilder.setLights(0xff00ff00, 300, 1000); } mBuilder.setAutoCancel(true); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(context, TimerActivity.class); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(TimerActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); // Create intent for cancelling the notification Context appContext = context.getApplicationContext(); Intent intent = new Intent(appContext, TimerReceiver.class); intent.setAction(CANCEL_NOTIFICATION); // Cancel the pending cancellation and create a new one PendingIntent pendingCancelIntent = PendingIntent.getBroadcast(appContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); if (uri != null) { //remove notification sound mBuilder.setSound(null); try { if (player != null && player.isPlaying()) { player.release(); player = new MediaPlayer(); } int currVolume = prefs.getInt("tone_volume", 0); if (currVolume != 0) { float log1 = (float) (Math.log(100 - currVolume) / Math.log(100)); player.setVolume(1 - log1, 1 - log1); } player.setDataSource(context, uri); player.prepare(); player.setLooping(false); player.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { // TODO Auto-generated method stub mp.release(); } }); player.start(); if (vibrate) { Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(1000); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (prefs.getBoolean("AutoClear", false)) { // Determine duration of notification sound int duration = 5000; if (uri != null) { MediaPlayer cancelPlayer = new MediaPlayer(); try { cancelPlayer.setDataSource(context, uri); cancelPlayer.prepare(); duration = Math.max(duration, cancelPlayer.getDuration() + 2000); } catch (java.io.IOException ex) { Log.e(TAG, "Cannot get sound duration: " + ex); duration = 30000; // on error, default to 30 seconds } finally { cancelPlayer.release(); } cancelPlayer.release(); } Log.v(TAG, "Notification duration: " + duration + " ms"); // Schedule cancellation AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmMgr.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + duration, pendingCancelIntent); } if (useAdvTime && advTimeString.length() > 0) { Intent broadcast = new Intent(); SharedPreferences.Editor editor = prefs.edit(); if (advTimeIndex < advTime.length) { editor.putInt("advTimeIndex", advTimeIndex + 1); String[] thisAdvTime = advTime[advTimeIndex].split("#"); // will be of format timeInMs#pathToSound int time = Integer.parseInt(thisAdvTime[0]); broadcast.putExtra("time", time); // Save new time editor.putLong("TimeStamp", new Date().getTime() + time); editor.putInt("LastTime", time); // editor.putString("NotificationUri", thisAdvTime[1]); mNM.cancelAll(); Log.v(TAG, "Starting next iteration of the timer service ..."); Intent rintent = new Intent(context, TimerReceiver.class); rintent.putExtra("SetTime", time); PendingIntent mPendingIntent = PendingIntent.getBroadcast(context, 0, rintent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager mAlarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mAlarmMgr.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + time, mPendingIntent); } else { broadcast.putExtra("stop", true); editor.putInt("advTimeIndex", 1); } broadcast.setAction(BROADCAST_RESET); context.sendBroadcast(broadcast); editor.apply(); } else if (prefs.getBoolean("AutoRestart", false)) { int time = pintent.getIntExtra("SetTime", 0); if (time != 0) { mNM.cancel(0); Log.v(TAG, "Restarting the timer service ..."); Intent rintent = new Intent(context, TimerReceiver.class); rintent.putExtra("SetTime", time); PendingIntent mPendingIntent = PendingIntent.getBroadcast(context, 0, rintent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager mAlarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mAlarmMgr.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + time, mPendingIntent); // Save new time SharedPreferences.Editor editor = prefs.edit(); editor.putLong("TimeStamp", new Date().getTime() + time); editor.putInt("LastTime", time); editor.apply(); Intent broadcast = new Intent(); broadcast.putExtra("time", time); broadcast.setAction(BROADCAST_RESET); context.sendBroadcast(broadcast); } } mNotificationManager.notify(0, mBuilder.build()); Log.d(TAG, "ALARM: alarm finished"); }
From source file:com.mattprecious.prioritysms.receiver.AlarmReceiver.java
private void doNotify(Context context, BaseProfile profile) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); MediaPlayer mediaPlayer = new MediaPlayer(); try {/*from w w w . j a v a 2 s .co m*/ if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL || profile.isOverrideSilent()) { mediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK); mediaPlayer.setAudioStreamType( profile.isOverrideSilent() ? AudioManager.STREAM_ALARM : AudioManager.STREAM_NOTIFICATION); mediaPlayer.setDataSource(context, profile.getRingtone()); mediaPlayer.prepare(); mediaPlayer.start(); if (profile.isVibrate()) { Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(VIBRATE_PATTERN, -1); } } } catch (IllegalArgumentException e) { Log.e(TAG, "failed to play audio", e); } catch (IOException e) { Log.e(TAG, "failed to play audio", e); } }
From source file:com.hhunj.hhudata.ForegroundService.java
private MediaPlayer ring() throws Exception, IOException { Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); MediaPlayer player = new MediaPlayer(); player.setDataSource(this, alert); final AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); if (audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION) != 0) { player.setAudioStreamType(AudioManager.STREAM_NOTIFICATION); player.setLooping(true);/* ww w . jav a 2 s. co m*/ player.prepare(); player.start(); } return player; }
From source file:com.orange.essentials.otb.ui.OtbTermsFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { mView = inflater.inflate(R.layout.otb_terms, container, false); LinearLayout llayout = (LinearLayout) mView.findViewById(R.id.otb_terms_layout); TextView headerTv = (TextView) llayout.findViewById(R.id.otb_header_tv_text); headerTv.setText(R.string.otb_home_terms_content); List<Term> terms = TrustBadgeManager.INSTANCE.getTerms(); for (Term term : terms) { View layoutToAdd = null;/*from w w w . ja va 2 s. c o m*/ if (term.getTermType() == TermType.VIDEO && Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { layoutToAdd = View.inflate(getActivity(), R.layout.otb_terms_video, null); TextView titleTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_video_title); final AutoResizingFrameLayout anchorView = (AutoResizingFrameLayout) layoutToAdd .findViewById(R.id.videoSurfaceContainer); if (mVideoViews == null) { mVideoViews = new ArrayList<>(); } mVideoViews.add(anchorView); SurfaceView videoSurface = (SurfaceView) layoutToAdd.findViewById(R.id.videoSurface); titleTv.setText(term.getTitleId()); SurfaceHolder videoHolder = videoSurface.getHolder(); MediaPlayer player = new MediaPlayer(); if (mPlayers == null) { mPlayers = new ArrayList<>(); } mPlayers.add(player); final VideoControllerView controller = new VideoControllerView(getContext()); VideoCallback videoCallback = new VideoCallback(player, controller, anchorView); videoHolder.addCallback(videoCallback); anchorView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { controller.show(); return false; } }); try { player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.setDataSource(getContext(), Uri.parse(getString(term.getContentId()))); player.setOnPreparedListener(videoCallback); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else if (term.getTermType() == TermType.TEXT) {//TermType.TEXT layoutToAdd = View.inflate(getActivity(), R.layout.otb_terms_text, null); TextView titleTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_text_title); TextView contentTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_text_content); titleTv.setText(term.getTitleId()); contentTv.setText(Html.fromHtml(getString(term.getContentId()))); contentTv.setMovementMethod(LinkMovementMethod.getInstance()); contentTv.setLinkTextColor(getResources().getColor(R.color.colorAccent)); } if (null != layoutToAdd) { llayout.addView(layoutToAdd); } if (terms.indexOf(term) != terms.size() - 1) { View.inflate(getActivity(), R.layout.otb_separator, llayout); } } return mView; }
From source file:com.massivcode.androidmusicplayer.services.MusicService.java
private void setNextMusicInfo(MediaPlayer mp, boolean isShuffle, boolean isRepeat) throws IOException { if (isShuffle) { mCurrentPosition = shuffle(mCurrentPlaylist.size()); } else {//from w w w .j a va 2 s . co m if (mCurrentPosition < getCurrentPlaylistSize()) { mCurrentPosition++; } else { mCurrentPosition = 0; } } mp.setDataSource(getApplicationContext(), switchIdToUri(mCurrentPlaylist.get(mCurrentPosition))); mCurrentMusicInfo = MusicInfoLoadUtil.getSelectedMusicInfo(getApplicationContext(), mCurrentPlaylist.get(mCurrentPosition)); if (isShuffle) { mp.prepare(); mp.start(); isReady = true; } else { if (isRepeat) { mp.prepare(); mp.start(); isReady = true; } else { if (mCurrentPosition != 0) { mp.prepare(); mp.start(); isReady = true; } else { mp.stop(); mp.reset(); isReady = false; } } } }
From source file:com.PPRZonDroid.MainActivity.java
/** * Play warning sound if airspeed goes below the selected value * * @param context/*from w w w.j av a 2 s . c o m*/ * @throws IllegalArgumentException * @throws SecurityException * @throws IllegalStateException * @throws IOException */ public void play_sound(Context context) throws IllegalArgumentException, SecurityException, IllegalStateException, IOException { Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); MediaPlayer mMediaPlayer = new MediaPlayer(); mMediaPlayer.setDataSource(context, soundUri); final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); //Set volume max!!! audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, audioManager.getStreamMaxVolume(audioManager.STREAM_SYSTEM), 0); if (audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM) != 0) { mMediaPlayer.setAudioStreamType(AudioManager.STREAM_SYSTEM); mMediaPlayer.setLooping(true); mMediaPlayer.prepare(); mMediaPlayer.start(); } }
From source file:org.botlibre.sdk.activity.ChatActivity.java
public MediaPlayer playAudio(String audio, boolean loop, boolean cache, boolean start) { try {//from w w w . j ava 2 s .co m Uri audioUri = null; if (cache) { audioUri = HttpGetVideoAction.fetchVideo(this, audio); } if (audioUri == null) { audioUri = Uri.parse(MainActivity.connection.fetchImage(audio).toURI().toString()); } final MediaPlayer audioPlayer = new MediaPlayer(); audioPlayer.setDataSource(getApplicationContext(), audioUri); audioPlayer.setOnErrorListener(new OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { Log.wtf("Audio error", "what:" + what + " extra:" + extra); audioPlayer.stop(); audioPlayer.release(); return true; } }); audioPlayer.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { audioPlayer.release(); runOnUiThread(new Runnable() { public void run() { try { beginListening(); } catch (Exception e) { Log.e("ChatActivity", "MediaPlayer: " + e.getMessage()); } } }); } }); audioPlayer.prepare(); audioPlayer.setLooping(loop); if (start) { audioPlayer.start(); } return audioPlayer; } catch (Exception exception) { Log.wtf(exception.toString(), exception); return null; } }
From source file:com.nest5.businessClient.Initialactivity.java
public void playSound(Context context) throws IllegalArgumentException, SecurityException, IllegalStateException, IOException { Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); MediaPlayer mMediaPlayer = new MediaPlayer(); mMediaPlayer.setDataSource(context, soundUri); final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (audioManager.getStreamVolume(AudioManager.STREAM_ALARM) != 0) { mMediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); mMediaPlayer.setLooping(false);/*from w ww .j a va 2 s . com*/ mMediaPlayer.prepare(); mMediaPlayer.start(); } }
From source file:com.tct.mail.compose.ComposeActivity.java
protected void sendOrSave(final boolean save, final boolean showToast) { // Check if user is a monkey. Monkeys can compose and hit send // button but are not allowed to send anything off the device. // TS: xiaolin.li 2015-01-08 EMAIL BUGFIX-893877 DEL_S /*if (ActivityManager.isUserAMonkey()) { return;//from w w w.ja v a 2 s. c o m }*/ // TS: xiaolin.li 2015-01-08 EMAIL BUGFIX-893877 DEL_E final SendOrSaveCallback callback = new SendOrSaveCallback() { // FIXME: unused private int mRestoredRequestId; @Override public void initializeSendOrSave(SendOrSaveTask sendOrSaveTask) { synchronized (mActiveTasks) { int numTasks = mActiveTasks.size(); if (numTasks == 0) { // Start service so we won't be killed if this app is // put in the background. startService(new Intent(ComposeActivity.this, EmptyService.class)); } mActiveTasks.add(sendOrSaveTask); } if (sTestSendOrSaveCallback != null) { sTestSendOrSaveCallback.initializeSendOrSave(sendOrSaveTask); } } @Override public void notifyMessageIdAllocated(SendOrSaveMessage sendOrSaveMessage, Message message) { synchronized (mDraftLock) { mDraftAccount = sendOrSaveMessage.mAccount; mDraftId = message.id; mDraft = message; if (sRequestMessageIdMap != null) { sRequestMessageIdMap.put(sendOrSaveMessage.requestId(), mDraftId); } // Cache request message map, in case the process is killed saveRequestMap(); } if (sTestSendOrSaveCallback != null) { sTestSendOrSaveCallback.notifyMessageIdAllocated(sendOrSaveMessage, message); } } @Override public Message getMessage() { synchronized (mDraftLock) { return mDraft; } } @Override public void sendOrSaveFinished(SendOrSaveTask task, boolean success) { // Update the last sent from account. if (mAccount != null) { MailAppProvider.getInstance().setLastSentFromAccount(mAccount.uri.toString()); } // TS: zhaotianyong 2015-03-25 EMAIL BUGFIX-954496 ADD_S // TS: zhaotianyong 2015-03-31 EMAIL BUGFIX-963249 ADD_S if (doSend) { ConnectivityManager mConnectivityManager = (ConnectivityManager) ComposeActivity.this .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = mConnectivityManager.getActiveNetworkInfo(); if (info == null) { Utility.showToast(ComposeActivity.this, R.string.send_failed); } } // TS: zhaotianyong 2015-03-31 EMAIL BUGFIX-963249 ADD_E // TS: zhaotianyong 2015-03-25 EMAIL BUGFIX-954496 ADD_E if (success) { // Successfully sent or saved so reset change markers discardChanges(); //TS: zheng.zou 2015-03-18 EMAIL FEATURE_996919 ADD_S if (!doSend && showToast) { Intent intent = new Intent(DRAFT_SAVED_ACTION); intent.setPackage(getString(R.string.email_package_name)); intent.putExtra(BaseColumns._ID, mDraftId); //send ordered broadcast to execute the event in sequence in different receivers, //ordered by priority sendOrderedBroadcast(intent, null); } //TS: zheng.zou 2015-03-18 EMAIL FEATURE_996919 ADD_E } else { // A failure happened with saving/sending the draft // TODO(pwestbro): add a better string that should be used // when failing to send or save //[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,08/05/2016,2635083 Utility.showShortToast(ComposeActivity.this, R.string.send_failed); //Toast.makeText(ComposeActivity.this, R.string.send_failed, Toast.LENGTH_SHORT) // .show(); } int numTasks; synchronized (mActiveTasks) { // Remove the task from the list of active tasks mActiveTasks.remove(task); numTasks = mActiveTasks.size(); } if (numTasks == 0) { // Stop service so we can be killed. stopService(new Intent(ComposeActivity.this, EmptyService.class)); } if (sTestSendOrSaveCallback != null) { sTestSendOrSaveCallback.sendOrSaveFinished(task, success); } } @Override public void incrementRecipientsTimesContacted(final List<String> recipients) { ComposeActivity.this.incrementRecipientsTimesContacted(recipients); } }; //TS: zheng.zou 2015-3-16 EMAIL BUGFIX_948927 Mod_S if (mReplyFromAccount == null && mAccount != null) { mReplyFromAccount = getDefaultReplyFromAccount(mAccount); } if (mReplyFromAccount != null) { setAccount(mReplyFromAccount.account); } //TS: zheng.zou 2015-3-16 EMAIL BUGFIX_948927 Mod_E // TS: yanhua.chen 2015-9-19 EMAIL BUGFIX_569665 ADD_S mIsSaveDraft = save; // TS: yanhua.chen 2015-9-19 EMAIL BUGFIX_569665 ADD_E final Spanned body = removeComposingSpans(mBodyView.getText()); SEND_SAVE_TASK_HANDLER.post(new Runnable() { @Override public void run() { final Message msg = createMessage(mReplyFromAccount, mRefMessage, getMode(), body); // TS: kaifeng.lu 2016-4-6 EMAIL BUGFIX_1909143 ADD_S if (/*!mIsClickIcon &&*/ !mEditDraft && (mIsSaveDraft || doSend)) {//[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,05/06/2016,2013535 String body1 = mBodyView.getText().toString().replace("\n", "\n\r"); SpannableString spannableString = new SpannableString(body1); StringBuffer bodySignature = new StringBuffer(body1); //[BUGFIX]-DEL begin by SCDTABLET.shujing.jin@tcl.com,05/17/2016,2013535,2148647 //if(mCachedSettings != null){ // bodySignature.append(convertToPrintableSignature(mCachedSettings.signature)); //} //[BUGFIX]-DEL end by SCDTABLET.shujing.jin spannableString = new SpannableString(bodySignature.toString()); msg.bodyHtml = spannedBodyToHtml(spannableString, true); msg.bodyText = bodySignature.toString(); } // TS: kaifeng.lu 2016-4-6 EMAIL BUGFIX_1909143 ADD_E mRequestId = sendOrSaveInternal(ComposeActivity.this, mReplyFromAccount, msg, mRefMessage, mQuotedTextView.getQuotedTextIfIncluded(), callback, SEND_SAVE_TASK_HANDLER, save, mComposeMode, mDraftAccount, mExtraValues); } }); // Don't display the toast if the user is just changing the orientation, // but we still need to save the draft to the cursor because this is how we restore // the attachments when the configuration change completes. if (showToast && (getChangingConfigurations() & ActivityInfo.CONFIG_ORIENTATION) == 0) { //TS: xinlei.sheng 2015-01-26 EMAIL FIXBUG_886976 MOD_S if (mLaunchContact) { mLaunchContact = false; } else { //TS: zheng.zou 2015-03-18 EMAIL FEATURE_996919 MDD_S if (!save) { //[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,08/05/2016,2635083 Utility.showToast(this, R.string.sending_message); //Toast.makeText(this, R.string.sending_message, // Toast.LENGTH_LONG).show(); } // Toast.makeText(this, save ? R.string.message_saved : R.string.sending_message, // Toast.LENGTH_LONG).show(); //TS: zheng.zou 2015-03-18 EMAIL FEATURE_996919 MOD_E } //TS: xinlei.sheng 2015-01-26 EMAIL FIXBUG_886976 MOD_E } // Need to update variables here because the send or save completes // asynchronously even though the toast shows right away. discardChanges(); updateSaveUi(); // If we are sending, finish the activity if (!save) { finish(); //TS: yanhua.chen 2015-6-15 EMAIL BUGFIX_1024081 ADD_S //TS: lin-zhou 2015-10-15 EMAIL BUGFIX_718388 MOD_S Uri soundUri = Uri.parse( "android.resource://" + getApplicationContext().getPackageName() + "/" + R.raw.email_sent); MediaPlayer player = new MediaPlayer(); try { if (soundUri != null) { player.setDataSource(getApplicationContext(), soundUri); } player.setAudioStreamType(AudioManager.STREAM_NOTIFICATION); player.prepare(); player.start(); } catch (IllegalArgumentException e) { LogUtils.e(LOG_TAG, "Send mail mediaPlayer get dataSource occur IllegalArgumentException"); } catch (SecurityException e) { LogUtils.e(LOG_TAG, "Send mail mediaPlayer get dataSource occur SecurityException"); } catch (IllegalStateException e) { LogUtils.e(LOG_TAG, "Send mail mediaPlayer get dataSource occur IllegalStateException"); } catch (IOException e) { LogUtils.e(LOG_TAG, "Send mail mediaPlayer get dataSource occur IOException"); } catch (NullPointerException e) { LogUtils.e(LOG_TAG, "Send mail mediaPlayer get dataSource occur NullPointerException"); } //TS: lin-zhou 2015-10-15 EMAIL BUGFIX_718388 MOD_E //TS: yanhua.chen 2015-6-15 EMAIL BUGFIX_1024081 ADD_E } }