本文整理汇总了Java中android.support.v4.media.session.MediaButtonReceiver.handleIntent方法的典型用法代码示例。如果您正苦于以下问题:Java MediaButtonReceiver.handleIntent方法的具体用法?Java MediaButtonReceiver.handleIntent怎么用?Java MediaButtonReceiver.handleIntent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.media.session.MediaButtonReceiver
的用法示例。
在下文中一共展示了MediaButtonReceiver.handleIntent方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent startIntent, int flags, int startId) {
if (startIntent != null) {
String action = startIntent.getAction();
String command = startIntent.getStringExtra(CMD_NAME);
if (ACTION_CMD.equals(action)) {
if (CMD_PAUSE.equals(command)) {
mMediaController.getTransportControls().pause();
}
} else {
// Try to handle the intent as a media button event wrapped by MediaButtonReceiver
MediaButtonReceiver.handleIntent(mMediaSession, startIntent);
}
}
return START_STICKY;
}
示例2: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent startIntent, int flags, int startId) {
if (startIntent != null) {
String action = startIntent.getAction();
String command = startIntent.getStringExtra(CMD_NAME);
if (ACTION_CMD.equals(action)) {
if (CMD_PAUSE.equals(command)) {
mPlaybackManager.handlePauseRequest();
} else if (CMD_STOP_CASTING.equals(command)) {
VideoCastManager.getInstance().disconnect();
}
} else {
// Try to handle the intent as a media button event wrapped by MediaButtonReceiver
MediaButtonReceiver.handleIntent(mSession, startIntent);
}
}
// Reset the delay handler to enqueue a message to stop the service if
// nothing is playing.
mDelayedStopHandler.removeCallbacksAndMessages(null);
mDelayedStopHandler.sendEmptyMessageDelayed(0, STOP_DELAY);
return START_STICKY;
}
示例3: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
/**
* (non-Javadoc)
* @see android.app.Service#onStartCommand(android.content.Intent, int, int)
*/
@Override
public int onStartCommand(Intent startIntent, int flags, int startId) {
if (startIntent != null) {
String action = startIntent.getAction();
String command = startIntent.getStringExtra(CMD_NAME);
if (ACTION_CMD.equals(action)) {
if (CMD_PAUSE.equals(command)) {
mPlaybackManager.handlePauseRequest();
} else if (CMD_STOP_CASTING.equals(command)) {
CastContext.getSharedInstance(this).getSessionManager().endCurrentSession(true);
}
} else {
// Try to handle the intent as a media button event wrapped by MediaButtonReceiver
MediaButtonReceiver.handleIntent(mSession, startIntent);
}
}
// Reset the delay handler to enqueue a message to stop the service if
// nothing is playing.
mDelayedStopHandler.removeCallbacksAndMessages(null);
mDelayedStopHandler.sendEmptyMessageDelayed(0, STOP_DELAY);
return START_STICKY;
}
示例4: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Timber.i("onStartCommand called");
super.onStartCommand(intent, flags, startId);
if (intent != null && MediaStoreUtil.hasPermission(this)) {
mBeQuiet = intent.getBooleanExtra(EXTRA_START_SILENT, false);
if (intent.hasExtra(Intent.EXTRA_KEY_EVENT)) {
MediaButtonReceiver.handleIntent(musicPlayer.getMediaSession(), intent);
Timber.i(intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT).toString());
} else if (ACTION_STOP.equals(intent.getAction())) {
stop();
}
}
return START_STICKY;
}
示例5: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if(L) Log.i(LOG_TAG, "Starting service");
if (intent != null && intent.getAction() != null) {
switch (intent.getAction()) {
case ACTION_PLAY:
if(L) Log.i(LOG_TAG, "Calling play");
mediaController.getTransportControls().play();
break;
case ACTION_STOP:
if(L) Log.i(LOG_TAG, "Calling stop");
mediaController.getTransportControls().stop();
break;
}
}
// receives and handles all media button key events and forwards
// to the media session which deals with them in its callback methods
MediaButtonReceiver.handleIntent(mediaSession, intent);
return super.onStartCommand(intent, flags, startId);
}
示例6: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null) {
String action = intent.getAction();
if (action != null) {
switch (action) {
case ACTION_STOP:
stop();
break;
case ACTION_PAUSE:
pause();
break;
case ACTION_RESUME:
resume();
break;
}
}
MediaButtonReceiver.handleIntent(mediaSession, intent);
}
return super.onStartCommand(intent, flags, startId);
}
示例7: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG, "onStartCommand");
castSession = castSessionManager.getCurrentCastSession();
if (sessionManagerListener == null) {
sessionManagerListener = new SessionManagerListenerImpl();
castSessionManager.addSessionManagerListener(sessionManagerListener);
}
String requestType = intent.getStringExtra(MediaRecorderService.REQUEST_TYPE);
Log.d(TAG, "onStartCommand received request: " + requestType);
if (requestType != null && requestType.equals(MediaRecorderService.REQUEST_TYPE_START)) {
Log.i(TAG, "Started service");
// After binding with activity, will hear setActivity() to start recording
}
else if (requestType != null && requestType.equals(MediaRecorderService.REQUEST_TYPE_STOP)) {
stop();
}
else {
MediaButtonReceiver.handleIntent(mediaSession, intent);
}
return START_STICKY;
}
示例8: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent startIntent, int flags, int startId) {
if (startIntent != null) {
String action = startIntent.getAction();
if(action!=null) {
if (action.equals(MediaTasks.ACTION_STOP)) {
stopSelf();
}else {
MediaTasks.executeTask(playbackManager, action);
}
}
MediaButtonReceiver.handleIntent(mediaSession, startIntent);
}
return START_NOT_STICKY;
}
示例9: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
//@AddTrace(name = "onStartCommand", enabled = true/*Optional*/)
public int onStartCommand(Intent intent, int flags, int startId) {
// checking for empty intent
if (intent == null) {
LogHelper.v(LOG_TAG, "Null-Intent received. Stopping self.");
stopForeground(true); // Remove notification
stopSelf();
}
// ACTION PLAY
else if (intent.getAction().equals(TransistorKeys.ACTION_PLAY)) {
LogHelper.v(LOG_TAG, "Service received command: PLAY");
// get URL of station from intent
if (intent.hasExtra(TransistorKeys.EXTRA_STATION)) {
mStation = intent.getParcelableExtra(TransistorKeys.EXTRA_STATION);
mStationID_Position = intent.getIntExtra(TransistorKeys.EXTRA_STATION_Position_ID, 0);
mStreamUri = mStation.getStreamUri().toString();
}
// update controller - start playback
mController.getTransportControls().play();
}
// ACTION STOP
else if (intent.getAction().equals(TransistorKeys.ACTION_STOP)) {
LogHelper.v(LOG_TAG, "Service received command: STOP");
// update controller - pause playback
mController.getTransportControls().pause();
}
// ACTION DISMISS
else if (intent.getAction().equals(TransistorKeys.ACTION_DISMISS)) {
LogHelper.v(LOG_TAG, "Service received command: DISMISS");
// update controller - stop playback
mController.getTransportControls().stop();
}
// listen for media button
MediaButtonReceiver.handleIntent(mSession, intent);
// default return value for media playback
return START_STICKY;
}
示例10: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.v(TAG, "Got an intent");
if (intent != null && intent.getAction() != null) {
Log.v(TAG, "Received intent:" + intent.getAction());
switch (intent.getAction()) {
case ACTION_STOP:
notifyDismissed();
closeConnection();
break;
case ACTION_SEARCH_FORWARDS:
handleSearchForwards();
break;
case ACTION_NEXT:
handleNextChannelRequest();
break;
case ACTION_PAUSE:
handlePauseRequest();
break;
case ACTION_PREVIOUS:
handlePreviousChannelRequest();
break;
case ACTION_SEARCH_BACKWARDS:
handleSearchBackwards();
break;
case ACTION_PLAY:
handlePlayRequest();
break;
default:
MediaButtonReceiver.handleIntent(mediaSession, intent);
}
}
return START_NOT_STICKY;
}
示例11: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
MediaButtonReceiver.handleIntent(mediaSession, intent);
return super.onStartCommand(intent, flags, startId);
}
示例12: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
MediaButtonReceiver.handleIntent(mSession, intent);
return super.onStartCommand(intent, flags, startId);
}
示例13: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// checking for empty intent
if (intent == null) {
LogHelper.v(LOG_TAG, "Null-Intent received. Stopping self.");
stopForeground(true); // Remove notification
stopSelf();
}
// ACTION PLAY
else if (intent.getAction().equals(ACTION_PLAY)) {
LogHelper.v(LOG_TAG, "Service received command: PLAY");
// get URL of station from intent
if (intent.hasExtra(EXTRA_STATION)) {
mStation = intent.getParcelableExtra(EXTRA_STATION);
mStationID = intent.getIntExtra(EXTRA_STATION_ID, 0);
mStreamUri = mStation.getStreamUri().toString();
}
// update controller - start playback
mController.getTransportControls().play();
}
// ACTION STOP
else if (intent.getAction().equals(ACTION_STOP)) {
LogHelper.v(LOG_TAG, "Service received command: STOP");
// update controller - pause playback
mController.getTransportControls().pause();
}
// ACTION DISMISS
else if (intent.getAction().equals(ACTION_DISMISS)) {
LogHelper.v(LOG_TAG, "Service received command: DISMISS");
// update controller - stop playback
if (mPlayback) {
mController.getTransportControls().stop();
}
// dismiss notification
NotificationHelper.stop();
// set media session in-active
mSession.setActive(false);
}
// ACTION NEXT
else if (intent.getAction().equals(ACTION_NEXT)) {
LogHelper.e(LOG_TAG, "Service received command:NEXT");
}
// ACTION PREVIOUS
else if (intent.getAction().equals(ACTION_PREVIOUS)) {
LogHelper.e(LOG_TAG, "Service received command: PREVIOUS");
}
// listen for media button
MediaButtonReceiver.handleIntent(mSession, intent);
// default return value for media playback
return START_STICKY;
}
示例14: onStartCommand
import android.support.v4.media.session.MediaButtonReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// checking for empty intent
if (intent == null) {
LogHelper.v(LOG_TAG, "Null-Intent received. Stopping self.");
stopForeground(true); // Remove notification
stopSelf();
}
// ACTION PLAY
else if (intent.getAction().equals(ACTION_PLAY)) {
LogHelper.v(LOG_TAG, "Service received command: PLAY");
// reset current station if necessary
if (mStation != null && mStation.getPlaybackState() != PLAYBACK_STATE_STOPPED) {
mStation.resetState();
// send local broadcast: stopped
Intent intentStateBuffering = new Intent();
intentStateBuffering.setAction(ACTION_PLAYBACK_STATE_CHANGED);
intentStateBuffering.putExtra(EXTRA_STATION, mStation);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentStateBuffering);
LogHelper.v(LOG_TAG, "LocalBroadcast: ACTION_PLAYBACK_STATE_CHANGED -> PLAYBACK_STATE_STOPPED");
}
// get URL of station from intent
if (intent.hasExtra(EXTRA_STATION)) {
mStation = intent.getParcelableExtra(EXTRA_STATION);
}
// update controller - start playback
mController.getTransportControls().play();
}
// ACTION STOP
else if (intent.getAction().equals(ACTION_STOP)) {
LogHelper.v(LOG_TAG, "Service received command: STOP");
// update controller - pause playback
mController.getTransportControls().pause();
}
// ACTION DISMISS
else if (intent.getAction().equals(ACTION_DISMISS)) {
LogHelper.v(LOG_TAG, "Service received command: DISMISS");
// update controller - stop playback
if (mStation != null && mStation.getPlaybackState() != PLAYBACK_STATE_STOPPED) {
mController.getTransportControls().stop();
}
}
// listen for media button
MediaButtonReceiver.handleIntent(mSession, intent);
// default return value for media playback
return START_STICKY;
}