2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.music;
19 import com.android.music.MusicUtils.ServiceToken;
21 import android.app.Activity;
22 import android.content.ComponentName;
23 import android.content.Intent;
24 import android.content.ServiceConnection;
25 import android.os.Bundle;
26 import android.os.IBinder;
27 import android.os.RemoteException;
29 public class MusicBrowserActivity extends Activity
30 implements MusicUtils.Defs {
32 private ServiceToken mToken;
34 public MusicBrowserActivity() {
38 * Called when the activity is first created.
41 public void onCreate(Bundle icicle) {
42 super.onCreate(icicle);
43 int activeTab = MusicUtils.getIntPref(this, "activetab", R.id.artisttab);
44 if (activeTab != R.id.artisttab
45 && activeTab != R.id.albumtab
46 && activeTab != R.id.songtab
47 && activeTab != R.id.playlisttab) {
48 activeTab = R.id.artisttab;
50 MusicUtils.activateTab(this, activeTab);
52 String shuf = getIntent().getStringExtra("autoshuffle");
53 if ("true".equals(shuf)) {
54 mToken = MusicUtils.bindToService(this, autoshuffle);
59 public void onDestroy() {
61 MusicUtils.unbindFromService(mToken);
66 private ServiceConnection autoshuffle = new ServiceConnection() {
67 public void onServiceConnected(ComponentName classname, IBinder obj) {
68 // we need to be able to bind again, so unbind
71 } catch (IllegalArgumentException e) {
73 IMediaPlaybackService serv = IMediaPlaybackService.Stub.asInterface(obj);
76 serv.setShuffleMode(MediaPlaybackService.SHUFFLE_AUTO);
77 } catch (RemoteException ex) {
82 public void onServiceDisconnected(ComponentName classname) {