I couldn't find a suitable plugin, so I decided to create my own. My goal is to activate silent mode using a JavaScript command, however, I am encountering an error with the undefined method getSystemService. It seems like there may be a problem with my imports. Can someone please offer assistance?
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
public class AudioControl extends CordovaPlugin {
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if (action.equals("echo")) {
AudioManager audiomanage = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
audiomanage.setRingerMode(AudioManager.RINGER_MODE_SILENT);
String message = args.getString(0);
this.echo(message, callbackContext);
return true;
}
return false;
}
}