我有一些代码,我运行方法MediaStore.Images.Media.insertImage(从源而不是文件名插入),此代码将图像保存到MediaStore并返回图像的uri.我知道当它因任何原因失败时它将返回null而不是uri.此图片已被许多人多次下载,并且每隔一段时间它将从此方法返回null.我从来没有遇到过这种情况,所以我不知道发生了什么.这可能发生的原因是什么?还有另一篇文章有相同的问题,但答案是MediaStore源代码的链接,但该链接转到一个页面说链接不可用.任何帮助,将不胜感激.谢谢.
删除我的SD卡后,我收到了这个错误,所以我知道这可能是一个原因,我不确定,但我觉得如果卡已满,也会发生这种情况.仍然只是想知道是否还有其他原因.
因此,我正在设置一个程序,播放收到消息,mms或短信时设置的声音.我得到它与SMS工作,但MMS没有做任何事情.以下是运行BroadcastReceiver的类的代码:
/**
* This class overrides the main BroadcastReceiver to play the tone
* at the given textSoundPath.
* @author Jesse Stewart
*
*/
public class TextMonitor extends BroadcastReceiver {
public static String textSoundPath; //this is the sound set to play when
//sms or mms is received.
@Override
public void onReceive(Context arg0, Intent arg1) {
MediaPlayer tonePlayer = new MediaPlayer();
try {
tonePlayer.setDataSource(textSoundPath);
} catch (Exception e) {
System.out.println("Couldn't set the media player sound!!!!!");
e.printStackTrace();
}
try {
tonePlayer.prepare();
} …Run Code Online (Sandbox Code Playgroud)