当前位置: 首页>>代码示例>>Java>>正文


Java Intent.ACTION_HEADSET_PLUG属性代码示例

本文整理汇总了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));
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:13,代码来源:WebRtcCallService.java

示例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;
        }
    }
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:21,代码来源:MusicService.java

示例3: onHeadsetConnection

public void onHeadsetConnection(ReturnInterface callbackfn) {
    headsetCallbackfn = callbackfn;

    IntentFilter filter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
    headsetPluggedReceiver = new HeadSetReceiver();
    getContext().registerReceiver(headsetPluggedReceiver, filter);
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:7,代码来源:PMedia.java

示例4: headsetState

@Override
public void headsetState() {
    if (headsetListener != null) {
        IntentFilter receiverFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
        registerReceiver(headsetListener, receiverFilter);
    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:7,代码来源:MusicXService.java

示例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;
}
 
开发者ID:XFY9326,项目名称:EarPhoneKeySet,代码行数:5,代码来源:Methods.java

示例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);
       }
}
 
开发者ID:dmllr,项目名称:IdealMedia,代码行数:56,代码来源:PlayerService.java

示例7: registerHeadsetPlugReceiver

public void registerHeadsetPlugReceiver() {
    IntentFilter filter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
    mHeadsetPlugReceiver = new HeadsetPlugBroadcastReceiver();
    mService.registerReceiver(mHeadsetPlugReceiver, filter);
}
 
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:5,代码来源:MusicService.java


注:本文中的android.content.Intent.ACTION_HEADSET_PLUG属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。