本文介绍了如何.release()由RingtoneManager实例化的MediaPlayer的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个默认的铃声在我的活动:

  remindRingtoneView =(的TextView)findViewById(R.id.remind_ringtone);remindRingtoneView.setText(RingtoneManager.getRingtone(
            NewReminder.this,ringtone_uri).getTitle(
            NewReminder.this));

这行之后,我已经有了一个调试线LogCat中与标签='铃声'和消息=

'成功创建了本土选手。

当我完成活动和系统垃圾回收器做它的好工作,我得到了在LogCat中=

一个警告消息

 '的MediaPlayer完成而不释放。

我怎么能释放呢?

答案是:

 铃声remind_ringtone = RingtoneManager.getRingtone(
            NewReminder.this,ringtone_uri);
remindRingtoneView.setText(remind_ringtone.getTitle(NewReminder.this));
remind_ringtone.stop();


解决方案

在你的程序, RingtoneManager.getRingtone 将一个对象返回铃声类。如果我们认为这个对象是 mRingTone ,然后调用 mRingTone.stop()将发布的MediaPlayer 对象。

I'm getting a default Ringtone in my Activity:

remindRingtoneView = (TextView) findViewById(R.id.remind_ringtone);

remindRingtoneView.setText(RingtoneManager.getRingtone(
            NewReminder.this, ringtone_uri).getTitle(
            NewReminder.this));

After this line I've got a debug line in LogCat with tag = 'Ringtone' and message =

'Successfully created a local player'.

When I finished Activity and system garbage collector do it's good job I got a warn message in LogCat =

'MediaPlayer finalized without being released'.

How I can release it?

Answer is:

Ringtone remind_ringtone = RingtoneManager.getRingtone(
            NewReminder.this, ringtone_uri);        
remindRingtoneView.setText(remind_ringtone.getTitle(NewReminder.this));
remind_ringtone.stop();
解决方案

In your program, RingtoneManager.getRingtone will return an object to Ringtone class. If we consider this object to be mRingTone, then invoking mRingTone.stop() will release the MediaPlayer object.

这篇关于如何.release()由RingtoneManager实例化的MediaPlayer的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 21:26