更新时间:2023-11-17 16:58:28
您需要在其中BroadcastReciever正在提供上下文传递(你不能使用这个
)
You need to pass in the context in which the BroadcastReciever is supplying (you can't use this
)
//---display the new SMS message---
Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
if(testString.equals("#silent"))
{
intent.putExtra(EXTRA_MESSAGE, SILENT_MESSAGE);
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
am.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}
else if(testString.equals("#volume"))
{
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
intent.putExtra(EXTRA_MESSAGE, VOLUME_MESSAGE);
}