AudioManger doesn't Work Application Crashes

帅比萌擦擦* 提交于 2019-12-25 18:38:14

问题


I'm working on an application .. but Audiomanager is not working i can't see any error my application got crash on phone I'm using AudioManager in BroadCastReciver Class when sms recive and text of sms is same of the particular text i've set the volume should be change silent to Normal mode.

if(message.equals(pwd)) {

    AudioManager au;
    au = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
    au.setRingerMode(AudioManager.RINGER_MODE_NORMAL);

    // Show Alert
    int duration = Toast.LENGTH_LONG;
    Toast toast = Toast.makeText(context, "Volumn Changed By Phone Finder App", duration);
    toast.show();
}
else {

    int duration = Toast.LENGTH_LONG;
    Toast toast = Toast.makeText(context,  "Doesn't match", duration);
    toast.show();
}

回答1:


Your code is working well without crash. Please paste log report of crash.

And its better to check context, message and pwd for NullPointer Exception.



来源:https://stackoverflow.com/questions/29984427/audiomanger-doesnt-work-application-crashes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!