Android Intent.ACTION\u耳机\u插头返回空值
nm和st1始终为空。Android Intent.ACTION\u耳机\u插头返回空值,android,android-intent,Android,Android Intent,nm和st1始终为空。 即使耳机已插入 当耳机插入或拔出手持设备时,安卓系统会触发Intent-Intent.ACTION\u耳机插头 您需要实现一个BroadcastReceiver来捕获发生的事件。 这是一个粘性事件,因此您可以使用以下快捷方式: public PluginResult execute(String action, JSONArray args, String callbackId) { try { Intent intent = new Int
即使耳机已插入 当耳机插入或拔出手持设备时,安卓系统会触发Intent-Intent.ACTION\u耳机插头 您需要实现一个BroadcastReceiver来捕获发生的事件。 这是一个粘性事件,因此您可以使用以下快捷方式:
public PluginResult execute(String action, JSONArray args, String callbackId) {
try {
Intent intent = new Intent(Intent.ACTION_HEADSET_PLUG);
String nm = intent.getStringExtra("name");
String st1 = intent.getStringExtra("state");
Log.v("nikhil","i="+intent+" name="+nm+" 2="+st1);
return new PluginResult(PluginResult.Status.OK);
} catch(Exception e) {
Log.e("MailApp", "Could not send email", e);
}
return null;
}
当耳机插入或拔出手持设备时,安卓系统会触发Intent-Intent.ACTION\耳机\插头 您需要实现一个BroadcastReceiver来捕获发生的事件。 这是一个粘性事件,因此您可以使用以下快捷方式:
public PluginResult execute(String action, JSONArray args, String callbackId) {
try {
Intent intent = new Intent(Intent.ACTION_HEADSET_PLUG);
String nm = intent.getStringExtra("name");
String st1 = intent.getStringExtra("state");
Log.v("nikhil","i="+intent+" name="+nm+" 2="+st1);
return new PluginResult(PluginResult.Status.OK);
} catch(Exception e) {
Log.e("MailApp", "Could not send email", e);
}
return null;
}