Example usage for android.content Intent getExtras

List of usage examples for android.content Intent getExtras

Introduction

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

Prototype

public @Nullable Bundle getExtras() 

Source Link

Document

Retrieves a map of extended data from the intent.

Usage

From source file:edgargtzg.popularmovies.MovieDetailsFragment.java

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

    // The detail Activity called via intent.  Inspect the intent for movie data.
    Intent intent = getActivity().getIntent();
    if (intent != null && intent.hasExtra(MovieItem.class.getCanonicalName())) {
        Bundle movieData = intent.getExtras();
        mMovieItem = movieData.getParcelable(MovieItem.class.getCanonicalName());

        if (mMovieItem != null) {

            // The MovieItemVideoAdapter will take data from a source and
            // use it to populate the list it's attached to.
            mMovieVideoAdapter = new MovieItemVideoAdapter(getActivity(), // The current context (this activity)
                    R.layout.list_video_movie_item, new ArrayList<MovieItemVideo>());

            // The MovieItemReviewAdapter will take data from a source and
            // use it to populate the list it's attached to.
            mMovieReviewAdapter = new MovieItemReviewAdapter(getActivity(), // The current context (this activity)
                    R.layout.list_review_movie_item, new ArrayList<MovieItemReview>());

            if (savedInstanceState != null) {
                mListOfVideos = (ArrayList<MovieItemVideo>) savedInstanceState.get(VIDEO_LIST_KEY);
                if (mListOfVideos != null) {
                    mMovieVideoAdapter.addAll(mListOfVideos);
                }/*from  w w w.  j  a  va 2  s.com*/
                mListOfReviews = (ArrayList<MovieItemReview>) savedInstanceState.get(REVIEW_LIST_KEY);
                if (mListOfReviews != null) {
                    mMovieReviewAdapter.addAll(mListOfReviews);
                }
            } else {
                mListOfVideos = new ArrayList<>();
                mListOfReviews = new ArrayList<>();
                updateMovieData(mMovieItem);
            }
        }
    }
}

From source file:com.test.hwautotest.emmagee.service.EmmageeService.java

@Override
public void onStart(Intent intent, int startId) {
    Log.i(LOG_TAG, "onStart");
    setForeground(true);//from   w  ww. j  a va2s.c  om
    super.onStart(intent, startId);

    pid = intent.getExtras().getInt("pid");
    uid = intent.getExtras().getInt("uid");
    processName = intent.getExtras().getString("processName");
    packageName = intent.getExtras().getString("packageName");
    settingTempFile = intent.getExtras().getString("settingTempFile");

    cpuInfo = new CpuInfo(getBaseContext(), pid, Integer.toString(uid));
    readSettingInfo(intent);
    delaytime = Integer.parseInt(time) * 1000;
    if (isFloating) {
        viFloatingWindow = LayoutInflater.from(this).inflate(R.layout.emmagee_floating, null);
        txtUnusedMem = (TextView) viFloatingWindow.findViewById(R.id.memunused);
        txtTotalMem = (TextView) viFloatingWindow.findViewById(R.id.memtotal);
        txtTraffic = (TextView) viFloatingWindow.findViewById(R.id.traffic);
        btnWifi = (Button) viFloatingWindow.findViewById(R.id.wifi);

        wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        if (wifiManager.isWifiEnabled()) {
            btnWifi.setText(R.string.closewifi);
        } else {
            btnWifi.setText(R.string.openwifi);
        }
        txtUnusedMem.setText(",??...");
        txtUnusedMem.setTextColor(android.graphics.Color.RED);
        txtTotalMem.setTextColor(android.graphics.Color.RED);
        txtTraffic.setTextColor(android.graphics.Color.RED);
        imgClose = (ImageView) viFloatingWindow.findViewById(R.id.emmagee_close);
        linLayout = (LinearLayout) viFloatingWindow.findViewById(R.id.Lin);
        imgMeminfo = (ImageView) viFloatingWindow.findViewById(R.id.emmagee_meminfo);
        createFloatingWindow();
    }
    createResultCsv();
    handler.postDelayed(task, 1000);
}

From source file:com.dwdesign.tweetings.fragment.AccountsFragment.java

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    switch (requestCode) {
    case REQUEST_SET_COLOR: {
        if (resultCode == Activity.RESULT_OK)
            if (data != null && data.getExtras() != null) {
                final int color = data.getIntExtra(Accounts.USER_COLOR, Color.WHITE);
                final ContentValues values = new ContentValues();
                values.put(Accounts.USER_COLOR, color);
                final String where = Accounts.USER_ID + " = " + mSelectedUserId;
                mResolver.update(Accounts.CONTENT_URI, values, where, null);
                getLoaderManager().restartLoader(0, null, this);
            }//  w  w w .  j  a v  a2 s  . c o  m
        break;
    }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.pushwoosh.plugin.pushnotifications.PushNotifications.java

private void checkMessage(Intent intent) {
    if (null != intent) {
        if (intent.hasExtra(PushManager.PUSH_RECEIVE_EVENT)) {
            doOnMessageReceive(intent.getExtras().getString(PushManager.PUSH_RECEIVE_EVENT));
        } else if (intent.hasExtra(PushManager.REGISTER_EVENT)) {
            doOnRegistered(intent.getExtras().getString(PushManager.REGISTER_EVENT));
        } else if (intent.hasExtra(PushManager.UNREGISTER_EVENT)) {
            doOnUnregistered(intent.getExtras().getString(PushManager.UNREGISTER_EVENT));
        } else if (intent.hasExtra(PushManager.REGISTER_ERROR_EVENT)) {
            doOnRegisteredError(intent.getExtras().getString(PushManager.REGISTER_ERROR_EVENT));
        } else if (intent.hasExtra(PushManager.UNREGISTER_ERROR_EVENT)) {
            doOnUnregisteredError(intent.getExtras().getString(PushManager.UNREGISTER_ERROR_EVENT));
        }//from  ww  w  .  j  a  va  2s .  co  m

        intent.removeExtra(PushManager.PUSH_RECEIVE_EVENT);
        intent.removeExtra(PushManager.REGISTER_EVENT);
        intent.removeExtra(PushManager.UNREGISTER_EVENT);
        intent.removeExtra(PushManager.REGISTER_ERROR_EVENT);
        intent.removeExtra(PushManager.UNREGISTER_ERROR_EVENT);

        cordova.getActivity().setIntent(intent);
    }
}

From source file:com.ibuildapp.romanblack.MultiContactsPlugin.MultiContactsPlugin.java

@Override
public void create() {
    try {//from   w  w w  . j ava2  s  .  c  om
        Intent currentIntent = getIntent();
        Bundle store = currentIntent.getExtras();
        widget = (Widget) store.getSerializable("Widget");

        if (widget == null) {
            handler.sendEmptyMessage(INITIALIZATION_FAILED);
            return;
        }

        if (widget.getPluginXmlData().length() == 0) {
            if (widget.getPathToXmlFile().length() == 0) {
                handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100);
                return;
            }
        }

        new Thread() {
            @Override
            public void run() {
                try {//ErrorLogging
                    if (widget.getPluginXmlData() != null && widget.getPluginXmlData().length() > 0) {
                        parser = new EntityParser(widget.getPluginXmlData());
                    } else {
                        String xmlData = readXmlFromFile(widget.getPathToXmlFile());
                        parser = new EntityParser(xmlData);
                    }
                    persons = parser.parse();

                    Statics.color1 = parser.getColor1();
                    Statics.color2 = parser.getColor2();
                    Statics.color3 = parser.getColor3();
                    Statics.color4 = parser.getColor4();
                    Statics.color5 = parser.getColor5();
                    Statics.isLight = parser.isLight();

                    PluginData.getInstance().setPersons(parser.getPersons());
                    PluginData.getInstance().prepareCounts();
                    // set background color/image/httpimage

                    handler.sendEmptyMessage(SET_ROOT_BACKGROUND);
                } catch (Exception e) {
                    Log.e(TAG, e.getMessage());
                    e.printStackTrace();
                }
            }
        }.start();
    } catch (Exception e) {
        Log.e(TAG, e.getMessage());
        e.printStackTrace();
    }
}

From source file:no.ntnu.idi.socialhitchhiking.myAccount.MyAccountCar.java

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

    int px = convertDpToPixel(160, getApp());
    if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
        if (data.getData() == null) {
            Bundle extras = data.getExtras();
            btm = (Bitmap) extras.get("data");
        } else if (data.getAction() != null) {
            btm = getBitmap(data.getData(), px, px);

        }/*from  ww  w .  j a v a 2s . co  m*/
        if (btm != null) {
            imageView.setImageBitmap(btm);
            imageView.invalidate();
            carChanged = true;
        }
    } else if (requestCode == ALBUM_REQUEST && resultCode == RESULT_OK) {
        btm = getBitmap(data.getData(), px, px);
        if (btm != null) {
            imageView.setImageBitmap(btm);
            imageView.invalidate();
            carChanged = true;
        }

    }
}

From source file:com.coloreight.plugin.socialAuth.SocialAuth.java

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

    fbCallbackManager.onActivityResult(requestCode, resultCode, intent);

    if (requestCode == SocialAuth.TWITTER_OAUTH_REQUEST) {
        if (resultCode == Activity.RESULT_OK) {
            Log.v(TAG, "On activity result with authtoken: " + intent.getExtras().keySet());

            for (String key : intent.getExtras().keySet()) {
                Object value = intent.getExtras().get(key);
                try {
                    String valueStr = value.toString();

                    Log.v("AUTH", String.format("%s %s (%s)", key, valueStr, value.getClass().getName()));
                } catch (NullPointerException e) {
                    Log.v(TAG, e.getMessage());
                }/*from w  w w.j a v a 2s  .  c  om*/
            }

            this.getTwitterSystemAccount(this.requestedTwitterAccountName, callbackContext);
        } else if (resultCode == Activity.RESULT_CANCELED) {
            callbackContext.error("Twitter auth activity canceled");
        }
    }
}

From source file:fr.bde_eseo.eseomega.lydia.LydiaActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    // Set view / call parent
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lydia);
    context = this;

    // Init intent flag
    INTENT_REQUEST intent_request = INTENT_REQUEST.ERROR;

    // Get intent parameters
    if (savedInstanceState == null) {
        Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        String action = intent.getAction();

        if (action != null) {

            // Check if intent's action is correct (obviously yes, but prevents Manifest modifications)
            if (action.equals(Intent.ACTION_VIEW)) {

                // Intent depuis Lydia
                intent_request = INTENT_REQUEST.FROM_LYDIA;

                // Get all parameters
                Uri qUri = intent.getData();

                // Order ID
                String sOrderID = qUri.getQueryParameter("id");

                if (sOrderID != null) {
                    orderID = Integer.parseInt(sOrderID);
                }/* ww  w.  j a v  a2 s .co  m*/

                orderType = qUri.getQueryParameter("cat");
            }

        } else if (extras != null) {

            // Intent interne
            intent_request = INTENT_REQUEST.FROM_APP;
            orderID = extras.getInt(Constants.KEY_LYDIA_ORDER_ID);
            orderType = extras.getString(Constants.KEY_LYDIA_ORDER_TYPE);

            // Demande de check ?  donc ask dj effectu
            if (extras.getBoolean(Constants.KEY_LYDIA_ORDER_ASKED)) {
                intent_request = INTENT_REQUEST.FROM_LYDIA;
            }
        }
    }

    // No intent received
    if (intent_request == INTENT_REQUEST.ERROR || orderID == -1) {
        Toast.makeText(context, "Erreur de l'application (c'est pas normal)", Toast.LENGTH_SHORT).show();
        close();
    }

    // Get objects
    userProfile = new UserProfile();
    userProfile.readProfilePromPrefs(context);
    prefsUser = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    // Init dialog
    dialogInit();

    // Get intent type
    if (intent_request == INTENT_REQUEST.FROM_APP) {

        /**
         * FROM_APP : On doit demander le numro de tlphone du client, puis lorsqu'il clique sur "Payer", effectuer une demande de paiement auprs de Lydia.
         * Il faut ensuite lancer l'Intent vers Lydia avec le bon numro de requte.
         *
         * A afficher :
         * - InputText tlphone
         * - Checkbox mmorisation numro
         * - Texte "lgal" sur le numro de tlphone
         * - Boutons Annuler / Valider  AsyncTask ask.php
         */
        dialogFromApp();

    } else {

        /**
         * FROM_LYDIA : L'activit vient d'tre ouverte aprs que le client ait cliqu sur "Accepter" depuis l'app Lydia.
         * Dans 100% des cas, le retour  notre activit se fait si il a eu un paiement valid.
         * Cependant, on vrifiera le statut de la commande auprs de notre serveur malgr tout.
         *
         * A afficher :
         * - Texte "tat de votre commande"  titre dialogue
         * - Texte status : actualis toutes les 3 secondes  asyncTask
         * - Bouton Fermer si status diffrent de "en cours"
         */
        dialogFromLydia();
    }
}

From source file:com.code.android.vibevault.ShowDetailsScreen.java

/** Create the activity, taking into account ongoing dialogs or already downloaded data.
*
* If there is a retained ParseShowDetailsPageTask, set its parent
* activity to the newly created ShowDetailsScreen (the old one was
* destroyed because of an orientation change or something.  This
* way, the ParseShowDetailsPageTask does not leak any of the Views
* from the old ShowDetailsScreen.  Also, grab the songs from the
* ParseShowDetailsPageTask to refresh the list of songs with.
*//*from  w  w  w.ja v  a2  s  .c  om*/
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.show_details_screen);
    Intent intent = getIntent();
    Bundle b = intent.getExtras();
    if (b != null) {
        show = (ArchiveShowObj) b.get("Show");
    }
    if (show == null) {
        if (intent.getScheme().equals("http")) {
            Uri link = intent.getData();
            String linkString = link.toString();
            if (linkString.contains("/download/")) {
                String[] paths = linkString.split("/");
                for (int i = 0; i < paths.length; i++) {
                    if (paths[i].equals("download")) {
                        show = new ArchiveShowObj(Uri.parse("http://www.archive.org/details/" + paths[i + 1]),
                                true);
                        show.setSelectedSong(linkString);
                    }
                }
            } else {
                show = new ArchiveShowObj(link, false);
            }
        }
    }

    //      
    //      

    showTitle = show.getArtistAndTitle();
    showLabel = (TextView) findViewById(R.id.ShowLabel);
    showLabel.setText(showTitle);

    trackList = (ListView) findViewById(R.id.SongsListView);
    trackList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> a, View v, int position, long id) {

            playShow(position);
            Intent i = new Intent(ShowDetailsScreen.this, NowPlayingScreen.class);
            startActivity(i);
        }
    });
    trackList.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            menu.add(Menu.NONE, VibeVault.ADD_SONG_TO_QUEUE, Menu.NONE, "Add to playlist");
            menu.add(Menu.NONE, VibeVault.DOWNLOAD_SONG, Menu.NONE, "Download Song");
            menu.add(Menu.NONE, VibeVault.EMAIL_LINK, Menu.NONE, "Email Link to Song");
        }
    });

    downloadLinks = new ArrayList<ArchiveSongObj>();
    Object retained = getLastNonConfigurationInstance();
    if (retained instanceof ParseShowDetailsPageTask) {
        workerTask = (ParseShowDetailsPageTask) retained;
        workerTask.setActivity(this);
        downloadLinks = workerTask.songs;
    } else if (show.getShowURL() != null) {

        workerTask = new ParseShowDetailsPageTask(this);
        workerTask.execute(show);
    }
}

From source file:com.openerp.base.ir.Attachment.java

public OEDataRow handleResult(int requestCode, Intent data) {
    Uri uri = null;/*  w  ww.  j  ava  2 s.  co  m*/
    Bitmap bitmap = null;
    switch (requestCode) {
    case REQUEST_AUDIO:
        uri = data.getData();
        break;
    case REQUEST_CAMERA:
        bitmap = (Bitmap) data.getExtras().get("data");
        uri = data.getData();
        break;
    case REQUEST_IMAGE:
        uri = data.getData();
        break;
    case REQUEST_FILE:
        uri = data.getData();
        break;
    default: // Single Attachment (share)
        uri = data.getParcelableExtra(Intent.EXTRA_STREAM);
        break;
    }

    return uriToDataRow(uri, bitmap);
}