本文整理汇总了Java中android.content.Intent.ACTION_HEADSET_PLUG属性的典型用法代码示例。如果您正苦于以下问题:Java Intent.ACTION_HEADSET_PLUG属性的具体用法?Java Intent.ACTION_HEADSET_PLUG怎么用?Java Intent.ACTION_HEADSET_PLUG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.ACTION_HEADSET_PLUG属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerWiredHeadsetStateReceiver
private void registerWiredHeadsetStateReceiver() {
wiredHeadsetStateReceiver = new WiredHeadsetStateReceiver();
String action;
if (Build.VERSION.SDK_INT >= 21) {
action = AudioManager.ACTION_HEADSET_PLUG;
} else {
action = Intent.ACTION_HEADSET_PLUG;
}
registerReceiver(wiredHeadsetStateReceiver, new IntentFilter(action));
}
示例2: onReceive
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action != null) {
switch (action) {
case Intent.ACTION_HEADSET_PLUG:
int state = intent.getIntExtra("state", -1);
switch (state) {
case 0:
Log.d(TAG, "Headset unplugged");
pause();
break;
case 1:
Log.d(TAG, "Headset plugged");
play();
break;
}
break;
}
}
}
示例3: onHeadsetConnection
public void onHeadsetConnection(ReturnInterface callbackfn) {
headsetCallbackfn = callbackfn;
IntentFilter filter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
headsetPluggedReceiver = new HeadSetReceiver();
getContext().registerReceiver(headsetPluggedReceiver, filter);
}
示例4: headsetState
@Override
public void headsetState() {
if (headsetListener != null) {
IntentFilter receiverFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
registerReceiver(headsetListener, receiverFilter);
}
}
示例5: isHeadSetUse
static boolean isHeadSetUse(Context ctx) {
IntentFilter iFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
Intent iStatus = ctx.registerReceiver(null, iFilter);
return (iStatus != null ? iStatus.getIntExtra("state", 0) : 0) == 1;
}
示例6: onCreate
@Override
public void onCreate() {
super.onCreate();
// initialize default output device
if (!BASS.BASS_Init(-1, 44100, 0)) {
return;
}
// look for plugins
plugins = "";
String path = getApplicationInfo().nativeLibraryDir;
String[] list = new File(path).list();
for (String s: list) {
int plug = BASS.BASS_PluginLoad(path+"/"+s, 0);
if (plug != 0) { // plugin loaded...
plugins += s + "\n"; // add it to the list
}
}
if (plugins.equals(""))
plugins = "no plugins - visit the BASS webpage to get some\n";
if(playerInterface != null) {
playerInterface.onPluginsLoaded(plugins);
}
BASS.BASS_SetConfig(BASS.BASS_CONFIG_BUFFER, 1000);
Log.w("BASS.BASS_CONFIG_BUFFER", "" + BASS.BASS_GetConfig(BASS.BASS_CONFIG_BUFFER));
// Pending Intend
Intent intent = new Intent(this, NavigationActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
pendIntent = PendingIntent.getActivity(this, 0, intent, 0);
//tracklist
loadTracks();
loadEqualizerValues();
tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(telephone, PhoneStateListener.LISTEN_CALL_STATE);
myBroadcastReceiver = new ServiceBroadcastReceiver();
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
intentFilter.addAction("android.media.VOLUME_CHANGED_ACTION");
intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
registerReceiver(myBroadcastReceiver, intentFilter);
ComponentName rcvMedia = new ComponentName(getPackageName(), MediaControlReceiver.class.getName());
mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
mAudioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
mAudioManager.registerMediaButtonEventReceiver(rcvMedia);
// Use the remote control APIs (if available) to set the playback state
if (Build.VERSION.SDK_INT >= 14 && remoteControlClient == null) {
registerRemoteControl(rcvMedia);
}
}
示例7: registerHeadsetPlugReceiver
public void registerHeadsetPlugReceiver() {
IntentFilter filter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
mHeadsetPlugReceiver = new HeadsetPlugBroadcastReceiver();
mService.registerReceiver(mHeadsetPlugReceiver, filter);
}