Example usage for android.content Intent getStringExtra

List of usage examples for android.content Intent getStringExtra

Introduction

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

Prototype

public String getStringExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.streaming.sweetplayer.PlayerActivity.java

@SuppressWarnings("unchecked")
@Override/*from  w w  w. j  a v a2s.  c o m*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.player);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    mActivity = this;
    mDataBase = new DataBaseHelper(mActivity);
    mImageLoader = new ImageLoader(mActivity.getApplicationContext());
    mLoadingBar = (ProgressBar) findViewById(R.id.loadingBar);

    Intent intent = getIntent();
    String action = intent.getAction();
    if (action != "see_player") {
        mLoadingBar.setVisibility(View.VISIBLE);
        Config.playerSongId = intent.getStringExtra(Config.ID);
        Config.playerSongArtistName = intent.getStringExtra(Config.ARTIST);
        Config.playerSongName = intent.getStringExtra(Config.NAME);
        Config.playerSongMp3 = intent.getStringExtra(Config.MP3);
        Config.playerSongDuration = intent.getStringExtra(Config.DURATION);
        Config.playerSongArtistImage = intent.getStringExtra(Config.IMAGE);
        Config.playerSongUrl = intent.getStringExtra(Config.URL);
        Config.playerSongDetailUrl = Config.SONG_DETAIL_URL + Config.playerSongId;
    }
    updatePlayerInfo();
    // logPlayerInfo();

    mSeekbarIntent = new Intent(BROADCAST_SEEKBAR);
    mProgressBar = (SeekBar) findViewById(R.id.progressBar);
    mCurrentDurationTextView = (TextView) findViewById(R.id.currentDuration);
    mTotalDurationTextView = (TextView) findViewById(R.id.totalDuration);
    mArtistNameTextView = (TextView) findViewById(R.id.playerArtistName);
    mArtistNameTextView.setText(sSongArtistName);
    mSongNameTextView = (TextView) findViewById(R.id.playerSongName);
    mSongNameTextView.setText(sSongName);
    mPlayPauseButton = (ImageButton) findViewById(R.id.playPauseButton);
    mPreviousButton = (ImageButton) findViewById(R.id.previousButton);
    mNextButton = (ImageButton) findViewById(R.id.nextButton);
    mRepeatButton = (ImageButton) findViewById(R.id.repeatButton);
    mShuffleButton = (ImageButton) findViewById(R.id.shuffleButton);
    mArtistImageView = (ImageView) findViewById(R.id.player_artist_image);
    loadImage(sSongArtistImage);
    setupPlayerButtons();
}

From source file:cm.aptoide.pt.RemoteInSearch.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    mPm = getPackageManager();//from w  ww .  ja  va2  s  .c  om
    if (data != null && data.hasExtra("settings")) {
        if (data.hasExtra("align"))
            order_lst = data.getStringExtra("align");
        redraw();
    } else {
        List<PackageInfo> getapks = mPm.getInstalledPackages(0);
        for (PackageInfo node : getapks) {
            if (node.packageName.equalsIgnoreCase(pkginfo.packageName)) {
                db.insertInstalled(apk_lst.get(requestCode).apkid);
                redraw();
                return;
            }
        }
        db.removeInstalled(apk_lst.get(requestCode).apkid);
        redraw();
    }
}

From source file:com.mobicage.rogerthat.registration.ContentBrandingRegistrationActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    T.UI();//from w ww.  j  a v  a  2 s.c om
    if (resultCode == RESULT_OK) {
        if (requestCode == ZXING_SCAN_QR_CODE_RESULT) {
            final String rawScanResult = intent.getStringExtra("SCAN_RESULT");
            L.d("scanned: " + rawScanResult);
            registerWithQRUrl(rawScanResult);
        }
    }
    if (mProgressDialog != null) {
        mProgressDialog.dismiss();
        mProgressDialog = null;
    }
}

From source file:com.winsuk.pebbletype.WatchCommunication.java

@Override
public void onReceive(Context context, Intent intent) {
    if (ACTION_PEBBLE_RECEIVE.equals(intent.getAction())) {
        final UUID receivedUuid = (UUID) intent.getSerializableExtra("uuid");

        // Pebble-enabled apps are expected to be good citizens and only inspect broadcasts containing their UUID
        if (!PEBBLE_APP_UUID.equals(receivedUuid)) {
            return;
        }/* w w  w.ja  v a  2  s.  c o m*/

        final int transactionId = intent.getIntExtra("transaction_id", -1);
        final String jsonData = intent.getStringExtra("msg_data");
        if (jsonData == null || jsonData.isEmpty()) {
            return;
        }

        try {
            final PebbleDictionary data = PebbleDictionary.fromJson(jsonData);
            receiveData(context, transactionId, data);
        } catch (JSONException e) {
            e.printStackTrace();
            return;
        }
    }

    if (ACTION_SMS_REPLY.equals(intent.getAction())) {
        boolean sent = getResultCode() == Activity.RESULT_OK;

        if (!sent)
            Log.w("com.winsuk.pebbletype", "Message failed to send. Result code: " + getResultCode());

        PebbleDictionary data = new PebbleDictionary();
        data.addUint8(sent ? KEY_MESSAGE_SENT : KEY_MESSAGE_NOT_SENT, (byte) 1);
        PebbleKit.sendDataToPebble(context, PEBBLE_APP_UUID, data);
    }
}

From source file:org.zywx.wbpalmstar.platform.push.PushRecieveMsgReceiver.java

private void oldPushNotification(Context context, Intent intent) {
    PushReportUtility.log("oldPushNotification->isForground = " + EBrowserActivity.isForground);
    if (EBrowserActivity.isForground) {
        if (mContext != null) {
            intent.putExtra("ntype", F_TYPE_PUSH);
            ((EBrowserActivity) mContext).handleIntent(intent);
        }/*w  w  w. j  a v a  2s  .c  om*/
    } else {
        CharSequence tickerText = intent.getStringExtra("title"); // ????
        Resources res = context.getResources();
        int icon = res.getIdentifier("icon", "drawable", intent.getPackage());
        long when = System.currentTimeMillis(); // ?
        // ??Nofification

        String notifyTitle = null;
        String pushMessage = intent.getStringExtra("message");
        String value = intent.getStringExtra("data"); // ??json
        try {
            JSONObject bodyJson = new JSONObject(value);
            notifyTitle = bodyJson.getString("msgName");// ?
        } catch (Exception e) {
            PushReportUtility.oe("onReceive", e);
        }
        if (TextUtils.isEmpty(notifyTitle)) {
            notifyTitle = intent.getStringExtra("widgetName");// msgNamewidgetName?
        }
        if (TextUtils.isEmpty(notifyTitle)) {
            notifyTitle = "APPCAN";// widgetNameAPPCAN?
        }
        CharSequence contentTitle = notifyTitle; // ?
        Intent notificationIntent = new Intent(context, EBrowserActivity.class); // ??Activity
        notificationIntent.putExtra("data", value);
        notificationIntent.putExtra("message", pushMessage);
        notificationIntent.putExtra("ntype", F_TYPE_PUSH);
        String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
        Notification notification = new Notification(icon, tickerText, when);
        notification.flags = Notification.FLAG_AUTO_CANCEL;
        notification.defaults |= Notification.DEFAULT_SOUND;
        if (Build.VERSION.SDK_INT >= 16) {
            try {
                Field priorityField = Notification.class.getField("priority");
                priorityField.setAccessible(true);
                priorityField.set(notification, 1);
            } catch (Exception e) {
                PushReportUtility.oe("onReceive", e);
            }
        }
        PendingIntent contentIntent = PendingIntent.getActivity(context, notificationNB, notificationIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        notification.setLatestEventInfo(context, contentTitle, tickerText, contentIntent);
        // NotificationNotificationManager
        mNotificationManager.notify(notificationNB, notification);
        notificationNB++;
    }
}

From source file:com.keithandthegirl.services.download.DownloadService.java

@TargetApi(8)
@Override/*  w ww .  j av  a2s.  c  o  m*/
protected void onHandleIntent(Intent requestIntent) {
    Log.v(TAG, "onHandleIntent : enter");

    mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    mOriginalRequestIntent = requestIntent;

    Resource resourceType = Resource.valueOf(requestIntent.getStringExtra(RESOURCE_TYPE_EXTRA));
    mCallback = requestIntent.getParcelableExtra(SERVICE_CALLBACK);

    Uri data = requestIntent.getData();
    String urlPath = requestIntent.getStringExtra("urlpath");
    String directory = requestIntent.getStringExtra("directory");

    String filename = data.getLastPathSegment();

    File root;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        switch (resourceType) {
        case MP3:
            root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PODCASTS);

            break;
        case MP4:
            root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);

            break;
        case M4V:
            root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);

            break;
        case JPG:
            root = getExternalCacheDir();
            filename = requestIntent.getLongExtra("id", -1) + ".jpg";

            break;
        default:
            root = getExternalCacheDir();

            break;
        }
    } else {
        root = Environment.getExternalStorageDirectory();
    }

    File outputDir = new File(root, directory);
    outputDir.mkdirs();

    File output = new File(outputDir, filename);
    if (output.exists()) {
        result = FragmentActivity.RESULT_OK;

        mCallback.send(result, getOriginalIntentBundle());

        Log.v(TAG, "onHandleIntent : exit, image exists");
        return;
    }

    switch (resourceType) {
    case MP3:
        Log.v(TAG, "onHandleIntent : saving mp3");

        savePodcast(requestIntent.getLongExtra("id", -1), requestIntent.getStringExtra("title"), urlPath,
                output);
        mCallback.send(result, getOriginalIntentBundle());

        break;

    case MP4:
        Log.v(TAG, "onHandleIntent : saving mp4");

        savePodcast(requestIntent.getLongExtra("id", -1), requestIntent.getStringExtra("title"), urlPath,
                output);
        mCallback.send(result, getOriginalIntentBundle());

        break;

    case M4V:
        Log.v(TAG, "onHandleIntent : saving m4v");

        savePodcast(requestIntent.getLongExtra("id", -1), requestIntent.getStringExtra("title"), urlPath,
                output);
        mCallback.send(result, getOriginalIntentBundle());

        break;

    case JPG:
        Log.v(TAG, "onHandleIntent : saving jpg");

        saveBitmap(requestIntent.getStringExtra("filename"), urlPath, output);
        mCallback.send(result, getOriginalIntentBundle());

        break;
    default:
        Log.w(TAG, "onHandleIntent : unknown extension '" + resourceType.getExtension() + "'");

        mCallback.send(REQUEST_INVALID, getOriginalIntentBundle());
        break;
    }

    Log.v(TAG, "onHandleIntent : exit");
}

From source file:com.hybris.mobile.activity.AbstractProductDetailActivity.java

/**
 * Handle incoming intents. Do not load a product if we already have one.
 *///ww w.  j a  v  a 2  s .co m
@Override
protected void onResume() {
    super.onResume();

    String[] options = { InternalConstants.PRODUCT_OPTION_BASIC, InternalConstants.PRODUCT_OPTION_CATEGORIES,
            InternalConstants.PRODUCT_OPTION_CLASSIFICATION, InternalConstants.PRODUCT_OPTION_DESCRIPTION,
            InternalConstants.PRODUCT_OPTION_GALLERY, InternalConstants.PRODUCT_OPTION_PRICE,
            InternalConstants.PRODUCT_OPTION_PROMOTIONS, InternalConstants.PRODUCT_OPTION_REVIEW,
            InternalConstants.PRODUCT_OPTION_STOCK, InternalConstants.PRODUCT_OPTION_VARIANT };

    String productCode = null;

    Intent intent = getIntent();

    // Direct Call
    if (intent.hasExtra(DataConstants.PRODUCT_CODE)) //direct call from search list for example
    {
        productCode = intent.getStringExtra(DataConstants.PRODUCT_CODE);
    }
    // NFC Call
    else if (intent.hasExtra(NfcAdapter.EXTRA_TAG)) //NFC 
    {
        Tag tag = getIntent().getExtras().getParcelable(NfcAdapter.EXTRA_TAG);

        Ndef ndef = Ndef.get(tag);
        NdefMessage message = ndef.getCachedNdefMessage();

        NdefRecord record = message.getRecords()[0];
        if (record.getTnf() == NdefRecord.TNF_WELL_KNOWN
                && Arrays.equals(record.getType(), NdefRecord.RTD_URI)) {
            productCode = RegexUtil
                    .getProductCode(new String(record.getPayload(), 1, record.getPayload().length - 1));
        }
    }
    // Call from another application (QR Code) 
    else if (StringUtils.equals(intent.getAction(), Intent.ACTION_VIEW)) {
        productCode = RegexUtil.getProductCode(intent.getDataString());
    }

    if (StringUtils.isNotEmpty(productCode)) {
        this.enableAndroidBeam(productCode);
    }

    // Only load if we don't have a product already
    if (mProduct == null) {
        populateProduct(productCode, options);
    }

    invalidateOptionsMenu();
}

From source file:com.scigames.slidegame.ObjectiveActivity.java

@Override
protected void onNewIntent(Intent i) {
    View thisView = findViewById(R.id.objective_page); //find view
    setContentView(thisView);/*from w w w  .ja  v a 2  s. c  om*/
    thisView.setBackgroundResource(R.drawable.bg_blank);
    objectiveImgNum = 0;
    objectiveImg = null;
    if (i.getExtras().getString("slideLevel") != null) {
        Log.d(TAG, "onNewIntent!");
        rfidIn = i.getStringExtra("rfid");
        studentIdIn = i.getStringExtra("studentId");
        slideLevelIn = i.getStringExtra("slideLevel");

        String thisSlideLevel = i.getExtras().getString("slideLevel");
        getObjectiveImages(slideLevelIn);
    }

}

From source file:com.ronnyml.sweetplayer.fragments.CommonFragment.java

private void getCommonData() {
    Intent intent = mActivity.getIntent();
    if (intent != null) {
        String url = "";
        if (intent.getBooleanExtra(Constants.IS_PLAYLIST, false)) {
            url = Constants.PLAYLIST_DETAIL_URL;
        } else if (intent.getBooleanExtra(Constants.IS_ARTIST, false)) {
            url = Constants.ARTISTS_DETAIL_URL;
        } else if (intent.getBooleanExtra(Constants.IS_GENRE, false)) {
            url = Constants.GENRE_DETAIL_URL;
        }/*from w  w w.j  av a 2  s  .  c  om*/

        String image = intent.getStringExtra(Constants.IMAGE);
        mImageView.setImageUrl(image, mImageLoader);

        String id = intent.getStringExtra(Constants.ID);
        getRequest(url + id);
    }
}

From source file:com.google.android.gcm.GCMBaseIntentService.java

@Override
public final void onHandleIntent(Intent intent) {
    try {//from w w w  .  j a v  a  2  s.  c o  m
        Context context = getApplicationContext();
        String action = intent.getAction();
        if (action.equals(INTENT_FROM_GCM_REGISTRATION_CALLBACK)) {
            handleRegistration(context, intent);
        } else if (action.equals(INTENT_FROM_GCM_MESSAGE)) {
            // checks for special messages
            String messageType = intent.getStringExtra(EXTRA_SPECIAL_MESSAGE);
            if (messageType != null) {
                if (messageType.equals(VALUE_DELETED_MESSAGES)) {
                    String sTotal = intent.getStringExtra(EXTRA_TOTAL_DELETED);
                    if (sTotal != null) {
                        try {
                            int total = Integer.parseInt(sTotal);
                            Log.v(TAG, "Received deleted messages " + "notification: " + total);
                            onDeletedMessages(context, total);
                        } catch (NumberFormatException e) {
                            Log.e(TAG, "GCM returned invalid number of " + "deleted messages: " + sTotal);
                        }
                    }
                } else {
                    // application is not using the latest GCM library
                    Log.e(TAG, "Received unknown special message: " + messageType);
                }
            } else {
                onMessage(context, intent);
            }
        } else if (action.equals(INTENT_FROM_GCM_LIBRARY_RETRY)) {
            String token = intent.getStringExtra(EXTRA_TOKEN);
            if (!TOKEN.equals(token)) {
                // make sure intent was generated by this class, not by a
                // malicious app.
                Log.e(TAG, "Received invalid token: " + token);
                return;
            }
            // retry last call
            if (GCMRegistrar.isRegistered(context)) {
                GCMRegistrar.internalUnregister(context);
            } else {
                GCMRegistrar.internalRegister(context, mSenderId);
            }
        }
    } finally {
        // Release the power lock, so phone can get back to sleep.
        // The lock is reference-counted by default, so multiple
        // messages are ok.

        // If onMessage() needs to spawn a thread or do something else,
        // it should use its own lock.
        /* synchronized (LOCK) {
        // sanity check for null as this is a public method
        if (sWakeLock != null) {
            Log.v(TAG, "Releasing wakelock");
            sWakeLock.release();
        } else {
            // should never happen during normal workflow
            Log.e(TAG, "Wakelock reference is null");
        }
         }*/
    }
}