Example usage for android.content Intent getStringArrayExtra

List of usage examples for android.content Intent getStringArrayExtra

Introduction

In this page you can find the example usage for android.content Intent getStringArrayExtra.

Prototype

public String[] getStringArrayExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:org.kontalk.service.msgcenter.MessageCenterService.java

@CommandHandler(name = { ACTION_ROSTER, ACTION_ROSTER_MATCH })
private boolean handleRoster(Intent intent, boolean canConnect) {
    if (canConnect && isConnected()) {
        Stanza iq;//from  ww  w  .  j  a v  a2s.  com

        if (ACTION_ROSTER_MATCH.equals(intent.getAction())) {
            iq = new RosterMatch();
            String[] list = intent.getStringArrayExtra(EXTRA_JIDLIST);

            for (String item : list) {
                ((RosterMatch) iq).addItem(item);
            }

            // directed to the probe component
            iq.setTo(XmppStringUtils.completeJidFrom("probe", mServer.getNetwork()));
        } else {
            iq = new RosterPacket();
        }

        String id = intent.getStringExtra(EXTRA_PACKET_ID);
        iq.setStanzaId(id);
        // iq default type is get

        sendPacket(iq);
    }
    return false;
}

From source file:com.cerema.cloud2.files.services.FileUploader.java

/**
 * Entry point to add one or several files to the queue of uploads.
 *
 * New uploads are added calling to startService(), resulting in a call to
 * this method. This ensures the service will keep on working although the
 * caller activity goes away./*from w ww  .  j av a 2  s. c  om*/
 */
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log_OC.d(TAG, "Starting command with id " + startId);

    if (intent.hasExtra(KEY_CANCEL_ALL) && intent.hasExtra(KEY_ACCOUNT)) {
        Account account = intent.getParcelableExtra(KEY_ACCOUNT);

        if (mCurrentUpload != null) {
            FileUploaderBinder fub = (FileUploaderBinder) mBinder;
            fub.cancel(account);
            return Service.START_NOT_STICKY;
        }
    }

    if (!intent.hasExtra(KEY_ACCOUNT) || !intent.hasExtra(KEY_UPLOAD_TYPE)
            || !(intent.hasExtra(KEY_LOCAL_FILE) || intent.hasExtra(KEY_FILE))) {
        Log_OC.e(TAG, "Not enough information provided in intent");
        return Service.START_NOT_STICKY;
    }
    int uploadType = intent.getIntExtra(KEY_UPLOAD_TYPE, -1);
    if (uploadType == -1) {
        Log_OC.e(TAG, "Incorrect upload type provided");
        return Service.START_NOT_STICKY;
    }
    Account account = intent.getParcelableExtra(KEY_ACCOUNT);
    if (!AccountUtils.exists(account, getApplicationContext())) {
        return Service.START_NOT_STICKY;
    }

    String[] localPaths = null, remotePaths = null, mimeTypes = null;
    OCFile[] files = null;
    if (uploadType == UPLOAD_SINGLE_FILE) {

        if (intent.hasExtra(KEY_FILE)) {
            files = new OCFile[] { intent.getParcelableExtra(KEY_FILE) };

        } else {
            localPaths = new String[] { intent.getStringExtra(KEY_LOCAL_FILE) };
            remotePaths = new String[] { intent.getStringExtra(KEY_REMOTE_FILE) };
            mimeTypes = new String[] { intent.getStringExtra(KEY_MIME_TYPE) };
        }

    } else { // mUploadType == UPLOAD_MULTIPLE_FILES

        if (intent.hasExtra(KEY_FILE)) {
            files = (OCFile[]) intent.getParcelableArrayExtra(KEY_FILE); // TODO
                                                                         // will
                                                                         // this
                                                                         // casting
                                                                         // work
                                                                         // fine?

        } else {
            localPaths = intent.getStringArrayExtra(KEY_LOCAL_FILE);
            remotePaths = intent.getStringArrayExtra(KEY_REMOTE_FILE);
            mimeTypes = intent.getStringArrayExtra(KEY_MIME_TYPE);
        }
    }

    FileDataStorageManager storageManager = new FileDataStorageManager(account, getContentResolver());

    boolean forceOverwrite = intent.getBooleanExtra(KEY_FORCE_OVERWRITE, false);
    boolean isInstant = intent.getBooleanExtra(KEY_INSTANT_UPLOAD, false);
    int localAction = intent.getIntExtra(KEY_LOCAL_BEHAVIOUR, LOCAL_BEHAVIOUR_FORGET);

    if (intent.hasExtra(KEY_FILE) && files == null) {
        Log_OC.e(TAG, "Incorrect array for OCFiles provided in upload intent");
        return Service.START_NOT_STICKY;

    } else if (!intent.hasExtra(KEY_FILE)) {
        if (localPaths == null) {
            Log_OC.e(TAG, "Incorrect array for local paths provided in upload intent");
            return Service.START_NOT_STICKY;
        }
        if (remotePaths == null) {
            Log_OC.e(TAG, "Incorrect array for remote paths provided in upload intent");
            return Service.START_NOT_STICKY;
        }
        if (localPaths.length != remotePaths.length) {
            Log_OC.e(TAG, "Different number of remote paths and local paths!");
            return Service.START_NOT_STICKY;
        }

        files = new OCFile[localPaths.length];
        for (int i = 0; i < localPaths.length; i++) {
            files[i] = obtainNewOCFileToUpload(remotePaths[i], localPaths[i],
                    ((mimeTypes != null) ? mimeTypes[i] : null));
            if (files[i] == null) {
                // TODO @andomaex add failure Notification
                return Service.START_NOT_STICKY;
            }
        }
    }

    OwnCloudVersion ocv = AccountUtils.getServerVersion(account);

    boolean chunked = FileUploader.chunkedUploadIsSupported(ocv);
    AbstractList<String> requestedUploads = new Vector<String>();
    String uploadKey = null;
    UploadFileOperation newUpload = null;
    try {
        for (int i = 0; i < files.length; i++) {
            newUpload = new UploadFileOperation(account, files[i], chunked, isInstant, forceOverwrite,
                    localAction, getApplicationContext());
            if (isInstant) {
                newUpload.setRemoteFolderToBeCreated();
            }
            newUpload.addDatatransferProgressListener(this);
            newUpload.addDatatransferProgressListener((FileUploaderBinder) mBinder);
            Pair<String, String> putResult = mPendingUploads.putIfAbsent(account, files[i].getRemotePath(),
                    newUpload);
            if (putResult != null) {
                uploadKey = putResult.first;
                requestedUploads.add(uploadKey);
            } // else, file already in the queue of uploads; don't repeat the request
        }

    } catch (IllegalArgumentException e) {
        Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage());
        return START_NOT_STICKY;

    } catch (IllegalStateException e) {
        Log_OC.e(TAG, "Bad information provided in intent: " + e.getMessage());
        return START_NOT_STICKY;

    } catch (Exception e) {
        Log_OC.e(TAG, "Unexpected exception while processing upload intent", e);
        return START_NOT_STICKY;

    }

    if (requestedUploads.size() > 0) {
        Message msg = mServiceHandler.obtainMessage();
        msg.arg1 = startId;
        msg.obj = requestedUploads;
        mServiceHandler.sendMessage(msg);
    }
    return Service.START_NOT_STICKY;
}

From source file:com.android.contacts.quickcontact.QuickContactActivity.java

private void processIntent(Intent intent) {
    if (intent == null) {
        finish();/*from w w  w  .  j ava2  s .  c  o  m*/
        return;
    }
    Uri lookupUri = intent.getData();

    // Check to see whether it comes from the old version.
    if (lookupUri != null && LEGACY_AUTHORITY.equals(lookupUri.getAuthority())) {
        final long rawContactId = ContentUris.parseId(lookupUri);
        lookupUri = RawContacts.getContactLookupUri(getContentResolver(),
                ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId));
    }
    mExtraMode = getIntent().getIntExtra(QuickContact.EXTRA_MODE, QuickContact.MODE_LARGE);
    mExtraPrioritizedMimeType = getIntent().getStringExtra(QuickContact.EXTRA_PRIORITIZED_MIMETYPE);
    final Uri oldLookupUri = mLookupUri;

    if (lookupUri == null) {
        finish();
        return;
    }
    mLookupUri = lookupUri;
    mExcludeMimes = intent.getStringArrayExtra(QuickContact.EXTRA_EXCLUDE_MIMES);
    if (oldLookupUri == null) {
        mContactLoader = (ContactLoader) getLoaderManager().initLoader(LOADER_CONTACT_ID, null,
                mLoaderContactCallbacks);
    } else if (oldLookupUri != mLookupUri) {
        // After copying a directory contact, the contact URI changes. Therefore,
        // we need to reload the new contact.
        destroyInteractionLoaders();
        mContactLoader = (ContactLoader) (Loader<?>) getLoaderManager().getLoader(LOADER_CONTACT_ID);
        mContactLoader.setLookupUri(mLookupUri);
        mCachedCp2DataCardModel = null;
    }
    mContactLoader.forceLoad();

    NfcHandler.register(this, mLookupUri);
}

From source file:org.secu3.android.ParamActivity.java

void update(Intent intent) {
    if (Secu3Service.EVENT_SECU3_SERVICE_STATUS_ONLINE.equals(intent.getAction())) {
        boolean isOnline = intent.getBooleanExtra(Secu3Service.EVENT_SECU3_SERVICE_STATUS, false);
        if (isOnline && !this.isOnline) {
            this.isOnline = true;
            paramsRead();//  w w  w .j a  v a2s.co  m
        }
        if (!isOnline) {
            isValid = false;
        }
        String s = isOnline ? getString(R.string.status_online) : getString(R.string.status_offline);
        textViewStatus.setText(s);
    } else if (Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PACKET.equals(intent.getAction())) {
        Secu3Packet packet = intent.getParcelableExtra(Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PARAM_PACKET);
        if (packet != null) {
            if (packet.getNameId() == R.string.op_comp_nc_title) {
                if (((ProtoFieldInteger) packet.getField(R.string.op_comp_nc_operation_title))
                        .getValue() == Secu3Packet.OPCODE_EEPROM_PARAM_SAVE) {
                    progressBar.setVisibility(ProgressBar.GONE);
                    Toast.makeText(this, String.format(getString(R.string.params_saved_error_code),
                            ((ProtoFieldInteger) packet.getField(R.string.op_comp_nc_operation_code_title))
                                    .getValue()),
                            Toast.LENGTH_LONG).show();
                }
            } else {
                packetUtils.setParamFromPacket(paramAdapter, packet);
            }
        }
    } else if (Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_SKELETON_PACKET.equals(intent.getAction())) {
        Secu3Packet packet = intent
                .getParcelableExtra(Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PARAM_SKELETON_PACKET);
        if (packet != null) {
            Skeletons.put(packet.getNameId(), packet);
        }
    } else if (Secu3Service.EVENT_SECU3_SERVICE_PROGRESS.equals(intent.getAction())) {
        int current = intent.getIntExtra(Secu3Service.EVENT_SECU3_SERVICE_PROGRESS_CURRENT, 0);
        int total = intent.getIntExtra(Secu3Service.EVENT_SECU3_SERVICE_PROGRESS_TOTAL, 0);
        progressBar.setIndeterminate(current == 0);
        progressBar.setMax(total);
        progressBar.setProgress(current);
        if (current == total) {
            startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PARAMETER, Uri.EMPTY, this,
                    Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PARAMETER_ID,
                            Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PARAMETER_FUNSET_NAMES));
        }
    } else if (Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PARAMETER.equals(intent.getAction())) {
        String funsetNames[] = intent
                .getStringArrayExtra(Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PARAMETER_FUNSET_NAMES);
        if (funsetNames != null) {
            progressBar.setVisibility(ProgressBar.GONE);
            PacketUtils.setFunsetNames(paramAdapter, funsetNames);
            paramAdapter.notifyDataSetChanged();
            isValid = true;
        }
    }
}

From source file:csh.cryptonite.Cryptonite.java

/** Called upon exit from other activities */
public synchronized void onActivityResult(final int requestCode, int resultCode, final Intent data) {

    switch (requestCode) {
    case SelectionMode.MODE_OPEN_ENCFS:
    case SelectionMode.MODE_OPEN_ENCFS_DB:
    case SelectionMode.MODE_OPEN_DEFAULT:
    case SelectionMode.MODE_OPEN_DEFAULT_DB:
    case SelectionMode.MODE_OPEN_UPLOAD_SOURCE:
    case SelectionMode.MODE_OPEN_CREATE:
        /* file dialog */
        if (resultCode == Activity.RESULT_OK && data != null) {
            currentReturnPath = data.getStringExtra(FileDialog.RESULT_EXPORT_PATHS);
            if (currentReturnPath != null) {
                switch (opMode) {
                case MOUNT_MODE:
                    opMode = prevMode;/*from  w w w . j  ava 2  s.  c  o m*/
                    if (localFragment != null) {
                        localFragment.updateMountButtons();
                    }
                    break;
                case SELECTLOCALENCFS_MODE:
                case SELECTDBENCFS_MODE:
                    /* TODO: This is now handle in FileDialog.java
                    if (requestCode != SelectionMode.MODE_OPEN_DEFAULT_DB) {
                    StorageManager.INSTANCE.setEncFSPath(currentReturnPath
                            .substring(currentDialogStartPath.length()));
                    } else {
                    StorageManager.INSTANCE.setEncFSPath(currentReturnPath
                            .substring(currentDialogRoot.length()));
                    }*/
                    updateDecryptDelayed = true;
                    break;
                case LOCALEXPORT_MODE:
                case DBEXPORT_MODE:
                case SELECTDBUPLOAD_MODE:
                case SELECTLOCALUPLOAD_MODE:
                    break;
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
        } else if (resultCode == RESULT_RETRY) {
            launchBuiltinFileBrowser();
        }
        break;
    case SelectionMode.MODE_OPEN_MULTISELECT:
    case SelectionMode.MODE_OPEN_MULTISELECT_DB:
        if (resultCode == Activity.RESULT_OK && data != null) {
            currentReturnPathList = data.getStringArrayExtra(FileDialog.RESULT_EXPORT_PATHS);
            if (currentReturnPathList != null && currentReturnPathList.length > 0) {
                /* Select destination directory for exported files */
                currentDialogLabel = Cryptonite.this.getString(R.string.select_exp);
                currentDialogButtonLabel = Cryptonite.this.getString(R.string.select_exp_short);
                currentDialogMode = SelectionMode.MODE_OPEN_EXPORT_TARGET;
                if (externalStorageIsWritable()) {
                    currentDialogStartPath = getDownloadDir().getPath();
                    File downloadDir = new File(currentDialogStartPath);
                    if (!downloadDir.exists()) {
                        downloadDir.mkdir();
                    }
                    if (!downloadDir.exists()) {
                        currentDialogStartPath = "/";
                    }
                } else {
                    currentDialogStartPath = "/";
                }
                currentDialogRoot = "/";
                currentDialogRootName = currentDialogRoot;
                if (StorageManager.INSTANCE.getEncFSStorage() != null) {
                    opMode = StorageManager.INSTANCE.getEncFSStorage().exportMode;
                } else {
                    return;
                }
                currentConfigFile = "";
                launchBuiltinFileBrowser();
            } else {
                currentOpenPath = data.getStringExtra(FileDialog.RESULT_OPEN_PATH);
                if (currentOpenPath != null && currentOpenPath.length() > 0) {
                    /* */
                } else {
                    currentUploadTargetPath = data.getStringExtra(FileDialog.RESULT_UPLOAD_PATH);
                    if (currentUploadTargetPath != null && currentUploadTargetPath.length() > 0) {
                        /* select file to upload */
                        currentDialogLabel = Cryptonite.this.getString(R.string.select_upload);
                        currentDialogButtonLabel = Cryptonite.this.getString(R.string.select_upload_short);
                        currentDialogMode = SelectionMode.MODE_OPEN_UPLOAD_SOURCE;
                        if (externalStorageIsWritable()) {
                            currentDialogStartPath = DirectorySettings.getGlobalExternalStorageDirectory()
                                    .getPath();
                        } else {
                            currentDialogStartPath = "/";
                        }
                        currentDialogRoot = "/";
                        currentDialogRootName = currentDialogRoot;
                        if (StorageManager.INSTANCE.getEncFSStorage() != null) {
                            opMode = StorageManager.INSTANCE.getEncFSStorage().uploadMode;
                        } else {
                            return;
                        }
                        currentConfigFile = "";
                        launchBuiltinFileBrowser();
                    }
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {

        } else if (resultCode == RESULT_ERROR) {
            Toast.makeText(this, R.string.decode_failure, Toast.LENGTH_LONG).show();
            jniResetVolume();
            StorageManager.INSTANCE.resetEncFSStorage();
            VirtualFileSystem.INSTANCE.clear();
        }
        break;
    case REQUEST_PREFS:
        SharedPreferences prefs = getBaseContext().getSharedPreferences(ACCOUNT_PREFS_NAME, 0);
        Editor prefEdit = prefs.edit();

        setupReadDirs(prefs.getBoolean("cb_extcache", false));

        DirectorySettings.INSTANCE.mntDir = prefs.getString("txt_mntpoint", defaultMntDir());

        /* If app folder settings have changed, we'll have to log out the user
         * from his Dropbox and restart the authentication from scratch during
         * the next login:
         */
        if (prefs.getBoolean("cb_appfolder", false) != mUseAppFolder) {
            prefEdit.putBoolean("dbDecided", true);
            prefEdit.commit();
            /* enforce re-authentication */
            DropboxInterface.INSTANCE.setDBApi(null);
            if (mLoggedIn) {
                Toast.makeText(Cryptonite.this, R.string.dropbox_forced_logout, Toast.LENGTH_LONG).show();
                logOut();
            }
        }
        break;
    case REQUEST_CODE_PICK_FILE_OR_DIRECTORY:
        /* from external OI file browser */
        if (resultCode == RESULT_OK && data != null) {
            // obtain the filename
            Uri fileUri = data.getData();
            if (fileUri != null) {
                currentReturnPath = fileUri.getPath();
            }
        }
        break;
    case CreateEncFS.CREATE_DB:
    case CreateEncFS.CREATE_LOCAL:
        break;
    case TextPreview.REQUEST_PREVIEW:
        break;
    default:
        Log.e(TAG, "Unknown request code");
    }
}

From source file:nz.ac.otago.psyanlab.common.designer.ExperimentDesignerActivity.java

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    switch (requestCode) {
    case REQUEST_EDIT_STAGE: {
        switch (resultCode) {
        case RESULT_OK:
            ArrayList<PropIdPair> props = data.getParcelableArrayListExtra(Args.EXPERIMENT_PROPS);
            long sceneId = data.getLongExtra(Args.SCENE_ID, -1);

            int height = data.getIntExtra(Args.STAGE_HEIGHT, -1);
            int width = data.getIntExtra(Args.STAGE_WIDTH, -1);
            int orientation = data.getIntExtra(Args.STAGE_ORIENTATION, Scene.ORIENTATION_LANDSCAPE);

            updateStageInScene(sceneId, props, orientation, width, height);
            break;

        default://from   w w  w.  ja  va2s .com
            break;
        }
        break;
    }
    case REQUEST_ASSET_IMPORT: {
        switch (resultCode) {
        case RESULT_OK:
            String[] paths = data.getStringArrayExtra(Args.PICKED_PATHS);
            Time t = new Time();
            t.setToNow();
            mExperiment.assets.put(ModelUtils.findUnusedKey(mExperiment.assets),
                    Asset.getFactory().newAsset(paths[0]));
            mAssetAdapter.notifyDataSetChanged();
            break;
        default:
            break;
        }
        break;
    }
    case REQUEST_SOURCE_IMPORT: {
        switch (resultCode) {
        case RESULT_OK:
            String[] paths = data.getStringArrayExtra(Args.PICKED_PATHS);
            Time t = new Time();
            t.setToNow();
            Source newSource = new Source();
            newSource.setExternalFile(new File(paths[0]));
            mExperiment.sources.put(ModelUtils.findUnusedKey(mExperiment.sources), newSource);
            mSourceAdapter.notifyDataSetChanged();
            break;
        default:
            break;
        }
    }
    default:
        break;
    }
}

From source file:org.planetmono.dcuploader.ActivityUploader.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == Application.ACTION_ADD_PHOTO || requestCode == Application.ACTION_TAKE_PHOTO) {
            /* add photo */

            if (contents.size() == 5)
                return;

            Uri selectedImage;/*  ww w  .  ja  v  a2 s  .c om*/
            Bitmap tbm;

            if (requestCode == Application.ACTION_ADD_PHOTO) {
                selectedImage = data.getData();
                tbm = getBitmapThumbnail(selectedImage);
            } /*else if (requestCode == Application.ACTION_TAKE_PHOTO && data != null && data.hasExtra("data")) {
               Bundle b = data.getExtras();
               String mpath = null;
                      
               Bitmap bitmap = (Bitmap) b.get("data");
               try {
                  if (tempFile == null) {
               File f = File.createTempFile("dcuploader_photo_",
                     ".jpg", Environment
                           .getDownloadCacheDirectory());
               FileOutputStream fo = new FileOutputStream(f);
               mpath = f.getAbsolutePath();
                      
               bitmap.compress(CompressFormat.JPEG, 90, fo);
               fo.close();
                  } else {
               mpath = tempFile.getAbsolutePath();
               tempFile = null;
                  }
               } catch (IOException e) {
                  e.printStackTrace();
                      
                  return;
               }
                      
               selectedImage = Uri.parse("file://" + mpath);
               tempFiles.add(mpath);
               tbm = getBitmapThumbnail(bitmap);
                      
               bitmap.recycle();
              } */else {
                /* take photo */
                selectedImage = Uri.fromFile(tempFile);
                tempFiles.add(tempFile.getAbsolutePath());
                tbm = getBitmapThumbnail(selectedImage);
            }

            Gallery g = (Gallery) findViewById(R.id.upload_images);

            int npos = 0;
            int pos = g.getSelectedItemPosition();

            if (pos == -1 || pos == 3) {
                contents.add(selectedImage);
                bitmaps.add(tbm);
                if (pos == 3)
                    npos = pos + 1;
            } else {
                contents.add(pos + 1, selectedImage);
                bitmaps.add(pos + 1, tbm);

                npos = pos + 1;
            }

            updateGallery();
            updateImageButtons();
            g.setSelection(npos);

            galleryChanged = true;
        } else if (requestCode == Application.ACTION_ADD_GALLERY) {
            /* add gallery */

            DatabaseHelper db = new DatabaseHelper(ActivityUploader.this);
            db.setFavorites(data.getStringArrayExtra("result"));
            db.close();

            openContextMenu(findViewById(R.id.upload_target));
        } else if (requestCode == Application.ACTION_SIGN_ON) {
            /* when signed on, go on. */

            publish();
        } else if (requestCode == Application.ACTION_PREFERENCES) {
            /* apply preferences */

            Log.d(Application.TAG, "reloading configuration...");

            reloadConfigurations();
            setDefaultImage();

            queryLocation(formLocation);
        }
    }
}

From source file:com.smithdtyler.prettygoodmusicplayer.NowPlaying.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent originIntent = getIntent();//from w  ww.j  ava2 s. c  o  m
    if (originIntent.getBooleanExtra("From_Notification", false)) {

        String artistName = originIntent.getStringExtra(ArtistList.ARTIST_NAME);
        String artistAbsPath = originIntent.getStringExtra(ArtistList.ARTIST_ABS_PATH_NAME);
        if (artistName != null && artistAbsPath != null) {
            Log.i(TAG, "Now Playing was launched from a notification, setting up its back stack");
            // Reference: https://developer.android.com/reference/android/app/TaskStackBuilder.html
            TaskStackBuilder tsb = TaskStackBuilder.create(this);
            Intent intent = new Intent(this, ArtistList.class);
            tsb.addNextIntent(intent);

            intent = new Intent(this, AlbumList.class);
            intent.putExtra(ArtistList.ARTIST_NAME, artistName);
            intent.putExtra(ArtistList.ARTIST_ABS_PATH_NAME, artistAbsPath);
            tsb.addNextIntent(intent);

            String albumName = originIntent.getStringExtra(AlbumList.ALBUM_NAME);
            if (albumName != null) {
                intent = new Intent(this, SongList.class);
                intent.putExtra(AlbumList.ALBUM_NAME, albumName);
                intent.putExtra(ArtistList.ARTIST_NAME, artistName);
                intent.putExtra(ArtistList.ARTIST_ABS_PATH_NAME, artistAbsPath);
                tsb.addNextIntent(intent);
            }
            intent = new Intent(this, NowPlaying.class);
            tsb.addNextIntent(intent);
            tsb.startActivities();
        }

    }

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    String theme = sharedPref.getString("pref_theme", getString(R.string.light));
    String size = sharedPref.getString("pref_text_size", getString(R.string.medium));
    Log.i(TAG, "got configured theme " + theme);
    Log.i(TAG, "got configured size " + size);

    // These settings were fixed in english for a while, so check for old style settings as well as language specific ones.
    if (theme.equalsIgnoreCase(getString(R.string.dark)) || theme.equalsIgnoreCase("dark")) {
        Log.i(TAG, "setting theme to " + theme);
        if (size.equalsIgnoreCase(getString(R.string.small)) || size.equalsIgnoreCase("small")) {
            setTheme(R.style.PGMPDarkSmall);
        } else if (size.equalsIgnoreCase(getString(R.string.medium)) || size.equalsIgnoreCase("medium")) {
            setTheme(R.style.PGMPDarkMedium);
        } else {
            setTheme(R.style.PGMPDarkLarge);
        }
    } else if (theme.equalsIgnoreCase(getString(R.string.light)) || theme.equalsIgnoreCase("light")) {
        Log.i(TAG, "setting theme to " + theme);
        if (size.equalsIgnoreCase(getString(R.string.small)) || size.equalsIgnoreCase("small")) {
            setTheme(R.style.PGMPLightSmall);
        } else if (size.equalsIgnoreCase(getString(R.string.medium)) || size.equalsIgnoreCase("medium")) {
            setTheme(R.style.PGMPLightMedium);
        } else {
            setTheme(R.style.PGMPLightLarge);
        }
    }

    boolean fullScreen = sharedPref.getBoolean("pref_full_screen_now_playing", false);
    currentFullScreen = fullScreen;
    if (fullScreen) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    setContentView(R.layout.activity_now_playing);

    if (savedInstanceState == null) {
        doBindService(true);
        startPlayingRequired = true;
    } else {
        doBindService(false);
        startPlayingRequired = false;
    }

    // Get the message from the intent
    Intent intent = getIntent();
    if (intent.getBooleanExtra(KICKOFF_SONG, false)) {
        desiredArtistName = intent.getStringExtra(ArtistList.ARTIST_NAME);
        desiredAlbumName = intent.getStringExtra(AlbumList.ALBUM_NAME);
        desiredArtistAbsPath = intent.getStringExtra(ArtistList.ARTIST_ABS_PATH_NAME);
        desiredSongAbsFileNames = intent.getStringArrayExtra(SongList.SONG_ABS_FILE_NAME_LIST);
        desiredAbsSongFileNamesPosition = intent.getIntExtra(SongList.SONG_ABS_FILE_NAME_LIST_POSITION, 0);
        desiredSongProgress = intent.getIntExtra(MusicPlaybackService.TRACK_POSITION, 0);

        Log.d(TAG,
                "Got song names " + desiredSongAbsFileNames + " position " + desiredAbsSongFileNamesPosition);

        TextView et = (TextView) findViewById(R.id.artistName);
        et.setText(desiredArtistName);

        et = (TextView) findViewById(R.id.albumName);
        et.setText(desiredAlbumName);
    }

    // The song name field will be set when we get our first update update from the service.

    final ImageButton pause = (ImageButton) findViewById(R.id.playPause);
    pause.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            playPause();
        }

    });

    ImageButton previous = (ImageButton) findViewById(R.id.previous);
    previous.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            previous();
        }

    });

    previous.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            jumpBack();
            return true;
        }
    });

    ImageButton next = (ImageButton) findViewById(R.id.next);
    next.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            next();
        }
    });

    final ImageButton shuffle = (ImageButton) findViewById(R.id.shuffle);
    shuffle.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            toggleShuffle();
        }
    });

    final ImageButton jumpback = (ImageButton) findViewById(R.id.jumpback);
    jumpback.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            jumpBack();
        }
    });

    SeekBar seekBar = (SeekBar) findViewById(R.id.songProgressBar);
    seekBar.setEnabled(true);
    seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        private int requestedProgress;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                Log.v(TAG, "drag location updated..." + progress);
                this.requestedProgress = progress;
                updateSongProgressLabel(progress);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            NowPlaying.this.userDraggingProgress = true;

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            Message msg = Message.obtain(null, MusicPlaybackService.MSG_SEEK_TO);
            msg.getData().putInt(MusicPlaybackService.TRACK_POSITION, requestedProgress);
            try {
                Log.i(TAG, "Sending a request to seek!");
                mService.send(msg);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            NowPlaying.this.userDraggingProgress = false;
        }

    });

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction("com.smithdtyler.ACTION_EXIT");
    exitReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            Log.i(TAG, "Received exit request, shutting down...");
            Intent msgIntent = new Intent(getBaseContext(), MusicPlaybackService.class);
            msgIntent.putExtra("Message", MusicPlaybackService.MSG_STOP_SERVICE);
            startService(msgIntent);
            finish();
        }

    };
    registerReceiver(exitReceiver, intentFilter);
}