當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。