问题
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