本文整理匯總了Java中android.media.session.MediaSession.setSessionActivity方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaSession.setSessionActivity方法的具體用法?Java MediaSession.setSessionActivity怎麽用?Java MediaSession.setSessionActivity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.media.session.MediaSession
的用法示例。
在下文中一共展示了MediaSession.setSessionActivity方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setup
import android.media.session.MediaSession; //導入方法依賴的package包/類
@Override
void setup() {
mHandlerThread = new HandlerThread(getClass().getName(), Process.THREAD_PRIORITY_BACKGROUND);
mHandlerThread.start();
mMediaSession = new MediaSession(mService, mService.getClass().getName());
mMediaSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS|MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
mMediaSession.setCallback(new Callback(), new Handler(mHandlerThread.getLooper()));
mMediaSession.setMediaButtonReceiver(PendingIntent.getBroadcast(
mService,
1,
new Intent(mService, MediaButtonIntentReceiver.class),
PendingIntent.FLAG_UPDATE_CURRENT
));
mMediaSession.setSessionActivity(PendingIntent.getActivity(
mService,
2,
NavUtils.makeLauncherIntent(mService),
PendingIntent.FLAG_UPDATE_CURRENT
));
}
示例2: onCreate
import android.media.session.MediaSession; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
ApplicationLoader.postInitApplication();
lastSelectedDialog = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE).getInt("auto_lastSelectedDialog", 0);
mediaSession = new MediaSession(this, "MusicService");
setSessionToken(mediaSession.getSessionToken());
mediaSession.setCallback(new MediaSessionCallback());
mediaSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
Context context = getApplicationContext();
Intent intent = new Intent(context, LaunchActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mediaSession.setSessionActivity(pi);
Bundle extras = new Bundle();
extras.putBoolean(SLOT_RESERVATION_QUEUE, true);
extras.putBoolean(SLOT_RESERVATION_SKIP_TO_PREV, true);
extras.putBoolean(SLOT_RESERVATION_SKIP_TO_NEXT, true);
mediaSession.setExtras(extras);
updatePlaybackState(null);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioPlayStateChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidStarted);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidReset);
}
示例3: onCreate
import android.media.session.MediaSession; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
LogHelper.d(TAG, "onCreate");
mPlayingQueue = new ArrayList<>();
mMusicProvider = new MusicProvider();
mPackageValidator = new PackageValidator(this);
// Start a new MediaSession
mSession = new MediaSession(this, "MusicService");
setSessionToken(mSession.getSessionToken());
mSession.setCallback(new MediaSessionCallback());
mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS |
MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
mPlayback = new LocalPlayback(this, mMusicProvider);
mPlayback.setState(PlaybackState.STATE_NONE);
mPlayback.setCallback(this);
mPlayback.start();
Context context = getApplicationContext();
Intent intent = new Intent(context, NowPlayingActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99 /*request code*/,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
mSession.setSessionActivity(pi);
mSessionExtras = new Bundle();
CarHelper.setSlotReservationFlags(mSessionExtras, true, true, true);
mSession.setExtras(mSessionExtras);
updatePlaybackState(null);
mMediaNotificationManager = new MediaNotificationManager(this);
mCastManager = ((UAMPApplication)getApplication()).getCastManager(getApplicationContext());
mCastManager.addVideoCastConsumer(mCastConsumer);
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
}
示例4: onCreate
import android.media.session.MediaSession; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
LogHelper.d(TAG, "onCreate");
mPlayingQueue = new ArrayList<>();
mMusicProvider = new MusicProvider();
mPackageValidator = new PackageValidator(this);
// Start a new MediaSession
mSession = new MediaSession(this, "MusicService");
setSessionToken(mSession.getSessionToken());
mSession.setCallback(new MediaSessionCallback());
mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS |
MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
mPlayback = new LocalPlayback(this, mMusicProvider);
mPlayback.setState(PlaybackState.STATE_NONE);
mPlayback.setCallback(this);
mPlayback.start();
Context context = getApplicationContext();
Intent intent = new Intent(context, NowPlayingActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99 /*request code*/,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
mSession.setSessionActivity(pi);
mSessionExtras = new Bundle();
CarHelper.setSlotReservationFlags(mSessionExtras, true, true, true);
WearHelper.setSlotReservationFlags(mSessionExtras, true, true);
WearHelper.setUseBackgroundFromTheme(mSessionExtras, true);
mSession.setExtras(mSessionExtras);
updatePlaybackState(null);
mMediaNotificationManager = new MediaNotificationManager(this);
mCastManager = VideoCastManager.getInstance();
mCastManager.addVideoCastConsumer(mCastConsumer);
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
}
示例5: register
import android.media.session.MediaSession; //導入方法依賴的package包/類
@Override
public void register(Context context, ComponentName mediaButtonReceiverComponent) {
downloadService = (DownloadService) context;
mediaSession = new MediaSession(downloadService, "DSub MediaSession");
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setComponent(mediaButtonReceiverComponent);
PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 0, mediaButtonIntent, 0);
mediaSession.setMediaButtonReceiver(mediaPendingIntent);
Intent activityIntent = new Intent(context, SubsonicFragmentActivity.class);
activityIntent.putExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD, true);
activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent activityPendingIntent = PendingIntent.getActivity(context, 0, activityIntent, 0);
mediaSession.setSessionActivity(activityPendingIntent);
mediaSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS | MediaSession.FLAG_HANDLES_MEDIA_BUTTONS);
mediaSession.setCallback(new EventCallback());
AudioAttributes.Builder audioAttributesBuilder = new AudioAttributes.Builder();
audioAttributesBuilder.setUsage(AudioAttributes.USAGE_MEDIA)
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC);
mediaSession.setPlaybackToLocal(audioAttributesBuilder.build());
mediaSession.setActive(true);
Bundle sessionExtras = new Bundle();
sessionExtras.putBoolean(WEAR_BACKGROUND_THEME, true);
sessionExtras.putBoolean(WEAR_RESERVE_SKIP_TO_PREVIOUS, true);
sessionExtras.putBoolean(WEAR_RESERVE_SKIP_TO_NEXT, true);
sessionExtras.putBoolean(AUTO_RESERVE_SKIP_TO_PREVIOUS, true);
sessionExtras.putBoolean(AUTO_RESERVE_SKIP_TO_NEXT, true);
mediaSession.setExtras(sessionExtras);
imageLoader = SubsonicActivity.getStaticImageLoader(context);
}
示例6: onCreate
import android.media.session.MediaSession; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
LogHelper.d(TAG, "onCreate");
mPlayingQueue = new ArrayList<>();
mMusicProvider = new MusicProvider();
mPackageValidator = new PackageValidator(this);
// Start a new MediaSession
mSession = new MediaSession(this, "MusicService");
setSessionToken(mSession.getSessionToken());
mSession.setCallback(new MediaSessionCallback());
mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS |
MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
mPlayback = new LocalPlayback(this, mMusicProvider);
mPlayback.setState(PlaybackState.STATE_NONE);
mPlayback.setCallback(this);
mPlayback.start();
Context context = getApplicationContext();
Intent intent = new Intent(context, NowPlayingActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99 /*request code*/,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
mSession.setSessionActivity(pi);
mSessionExtras = new Bundle();
CarHelper.setSlotReservationFlags(mSessionExtras, true, true, true);
WearHelper.setSlotReservationFlags(mSessionExtras, true, true);
WearHelper.setUseBackgroundFromTheme(mSessionExtras, true);
mSession.setExtras(mSessionExtras);
updatePlaybackState(null);
mMediaNotificationManager = new MediaNotificationManager(this);
mCastManager = VideoCastManager.getInstance();
mCastManager.addVideoCastConsumer(mCastConsumer);
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
}
示例7: onCreate
import android.media.session.MediaSession; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
ApplicationLoader.postInitApplication();
lastSelectedDialog = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE).getInt("auto_lastSelectedDialog", 0);
mediaSession = new MediaSession(this, "MusicService");
setSessionToken(mediaSession.getSessionToken());
mediaSession.setCallback(new MediaSessionCallback());
mediaSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
Context context = getApplicationContext();
Intent intent = new Intent(context, LaunchActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mediaSession.setSessionActivity(pi);
Bundle extras = new Bundle();
extras.putBoolean(SLOT_RESERVATION_QUEUE, true);
extras.putBoolean(SLOT_RESERVATION_SKIP_TO_PREV, true);
extras.putBoolean(SLOT_RESERVATION_SKIP_TO_NEXT, true);
mediaSession.setExtras(extras);
updatePlaybackState(null);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messagePlayingPlayStateChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messagePlayingDidStarted);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messagePlayingDidReset);
}
示例8: onCreate
import android.media.session.MediaSession; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
LogHelper.d(TAG, "onCreate");
mPlayingQueue = new ArrayList<>();
mMusicProvider = new MusicProvider();
mPackageValidator = new PackageValidator(this);
// Start a new MediaSession
mSession = new MediaSession(this, "MusicService");
setSessionToken(mSession.getSessionToken());
mSession.setCallback(new MediaSessionCallback());
mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS |
MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
mPlayback = new LocalPlayback(this, mMusicProvider);
mPlayback.setState(PlaybackState.STATE_NONE);
mPlayback.setCallback(this);
mPlayback.start();
Context context = getApplicationContext();
Intent intent = new Intent(context, NowPlayingActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99 /*request code*/,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
mSession.setSessionActivity(pi);
mSessionExtras = new Bundle();
CarHelper.setSlotReservationFlags(mSessionExtras, true, true, true);
WearHelper.setSlotReservationFlags(mSessionExtras, true, true);
WearHelper.setUseBackgroundFromTheme(mSessionExtras, true);
mSession.setExtras(mSessionExtras);
updatePlaybackState(null);
mMediaNotificationManager = new MediaNotificationManager(this);
mCastManager = VideoCastManager.getInstance();
mCastManager.addVideoCastConsumer(mCastConsumer);
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
IntentFilter filter = new IntentFilter(CarHelper.ACTION_MEDIA_STATUS);
mCarConnectionReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String connectionEvent = intent.getStringExtra(CarHelper.MEDIA_CONNECTION_STATUS);
mIsConnectedToCar = CarHelper.MEDIA_CONNECTED.equals(connectionEvent);
LogHelper.i(TAG, "Connection event to Android Auto: ", connectionEvent,
" isConnectedToCar=", mIsConnectedToCar);
}
};
registerReceiver(mCarConnectionReceiver, filter);
}