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 android.app.Activity;
20 import android.content.ComponentName;
21 import android.content.Intent;
22 import android.content.ServiceConnection;
23 import android.os.Bundle;
24 import android.os.IBinder;
25 import android.os.RemoteException;
27 public class MusicBrowserActivity extends Activity
28 implements MusicUtils.Defs {
30 public MusicBrowserActivity() {
34 * Called when the activity is first created.
37 public void onCreate(Bundle icicle) {
38 super.onCreate(icicle);
39 int activeTab = MusicUtils.getIntPref(this, "activetab", R.id.artisttab);
40 if (activeTab != R.id.artisttab
41 && activeTab != R.id.albumtab
42 && activeTab != R.id.songtab
43 && activeTab != R.id.playlisttab) {
44 activeTab = R.id.artisttab;
46 MusicUtils.activateTab(this, activeTab);
48 String shuf = getIntent().getStringExtra("autoshuffle");
49 if ("true".equals(shuf)) {
50 bindService((new Intent()).setClass(this, MediaPlaybackService.class), autoshuffle, 0);
55 public void onDestroy() {
56 MusicUtils.unbindFromService(this);
60 private ServiceConnection autoshuffle = new ServiceConnection() {
61 public void onServiceConnected(ComponentName classname, IBinder obj) {
62 // we need to be able to bind again, so unbind
65 } catch (IllegalArgumentException e) {
67 IMediaPlaybackService serv = IMediaPlaybackService.Stub.asInterface(obj);
70 serv.setShuffleMode(MediaPlaybackService.SHUFFLE_AUTO);
71 } catch (RemoteException ex) {
76 public void onServiceDisconnected(ComponentName classname) {