Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
142 views
in Technique[技术] by (71.8m points)

android - AudioManger doesn't Work Application Crashes

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();
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...