Example usage for android.content Intent hasExtra

List of usage examples for android.content Intent hasExtra

Introduction

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

Prototype

public boolean hasExtra(String name) 

Source Link

Document

Returns true if an extra value is associated with the given name.

Usage

From source file:mobisocial.socialkit.musubi.Musubi.java

public void setDataFromIntent(Intent intent) {
    if (intent.hasExtra(EXTRA_FEED_URI)) {
        mFeed = new DbFeed(this, (Uri) intent.getParcelableExtra(EXTRA_FEED_URI));
    }//from  ww  w.  jav a2s. c o m
    if (mObj == null) {
        if (intent.hasExtra(EXTRA_OBJ_URI)) {
            mObj = objForUri((Uri) intent.getParcelableExtra(EXTRA_OBJ_URI));
        } else {
            mObj = objForUri(intent.getData());
        }
    }
}

From source file:com.dsi.ant.antplus.pluginsampler.bloodpressure.Activity_BloodPressureSampler.java

private void resetPcc() {
    //Release the old access if it exists
    if (releaseHandle != null) {
        releaseHandle.close();/*  w w w .  j  a  va2 s  .  com*/
    }

    clearLayoutList();

    Intent intent = getIntent();
    if (intent.hasExtra(Activity_MultiDeviceSearchSampler.EXTRA_KEY_MULTIDEVICE_SEARCH_RESULT)) {
        // device has already been selected through the multi-device search
        MultiDeviceSearchResult result = intent
                .getParcelableExtra(Activity_MultiDeviceSearchSampler.EXTRA_KEY_MULTIDEVICE_SEARCH_RESULT);
        releaseHandle = AntPlusBloodPressurePcc.requestAccess(this, result.getAntDeviceNumber(), 0,
                mResultReceiver, mDeviceStateChangeReceiver);
    } else {
        // starts the plugins UI search
        releaseHandle = AntPlusBloodPressurePcc.requestAccess(this, this, mResultReceiver,
                mDeviceStateChangeReceiver);
    }
}

From source file:com.squareup.leakcanary.internal.DisplayLeakActivity.java

@SuppressWarnings("unchecked")
@Override/*from   w w w .  j  a  v a2 s  . c o  m*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        visibleLeakRefKey = savedInstanceState.getString("visibleLeakRefKey");
    } else {
        Intent intent = getIntent();
        if (intent.hasExtra(SHOW_LEAK_EXTRA)) {
            visibleLeakRefKey = intent.getStringExtra(SHOW_LEAK_EXTRA);
        }
    }

    leaks = (List<AnalyzedHeap>) getLastNonConfigurationInstance();

    setContentView(R.layout.leak_canary_display_leak);

    listView = findViewById(R.id.leak_canary_display_leak_list);
    failureView = findViewById(R.id.leak_canary_display_leak_failure);
    actionButton = findViewById(R.id.leak_canary_action);

    updateUi();
}

From source file:com.folioreader.activity.FolioActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ACTION_CONTENT_HIGHLIGHT && resultCode == RESULT_OK && data.hasExtra(TYPE)) {

        String type = data.getStringExtra(TYPE);
        if (type.equals(CHAPTER_SELECTED)) {
            mChapterPosition = data.getIntExtra(SELECTED_CHAPTER_POSITION, 0);
            int spineRefrencesPos = AppUtil.getSpineRefrecePos(mSpineReferences,
                    mTocReferences.get(mChapterPosition));
            mFolioPageViewPager.setCurrentItem(spineRefrencesPos);
        } else if (type.equals(HIGHLIGHT_SELECTED)) {
            Highlight highlight = data.getParcelableExtra(HIGHLIGHT_ITEM);
            int position = highlight.getCurrentPagerPostion();
            mFolioPageViewPager.setCurrentItem(position);
            WebViewPosition webViewPosition = new WebViewPosition();
            webViewPosition.setWebviewPos(highlight.getCurrentWebviewScrollPos());
            BUS.post(webViewPosition);//from w ww.j a va  2 s.c o m
        }
    }
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.repolist);/*from   w  ww . jav a2 s. com*/

    db = new DbHandler(this);

    Intent i = getIntent();
    if (i.hasExtra("empty")) {
        final String uri = i.getStringExtra("uri");
        AlertDialog alrt = new AlertDialog.Builder(this).create();
        alrt.setTitle(getString(R.string.title_repo_alrt));
        alrt.setIcon(android.R.drawable.ic_dialog_alert);
        alrt.setMessage(getString(R.string.myrepo_alrt) + uri);
        alrt.setButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                db.addServer(uri);
                change = true;
                redraw();
                return;
            }
        });
        alrt.setButton2("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                return;
            }
        });
        alrt.show();
    } else if (i.hasExtra("uri")) {
        String uri = i.getStringExtra("uri");
        Vector<String> new_serv_lst = getRemoteServLst(uri);
        for (final String srv : new_serv_lst) {
            AlertDialog alrt = new AlertDialog.Builder(this).create();
            alrt.setTitle(getString(R.string.title_repo_alrt));
            alrt.setIcon(android.R.drawable.ic_dialog_alert);
            alrt.setMessage(getString(R.string.newrepo_alrt) + srv);
            alrt.setButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    db.addServer(srv);
                    change = true;
                    redraw();
                    return;
                }
            });
            alrt.setButton2("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    return;
                }
            });
            alrt.show();
        }
    } else if (i.hasExtra("newrepo")) {
        final String repo = i.getStringExtra("newrepo");
        AlertDialog alrt = new AlertDialog.Builder(this).create();
        alrt.setTitle(getString(R.string.title_repo_alrt));
        alrt.setIcon(android.R.drawable.ic_dialog_alert);
        alrt.setMessage(getString(R.string.newrepo_alrt) + repo);
        alrt.setButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                db.addServer(repo);
                change = true;
                redraw();
                return;
            }
        });
        alrt.setButton2("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                //exit
            }
        });
        alrt.show();
    }
}

From source file:com.digitalarx.android.files.services.FileDownloader.java

/**
 * Entry point to add one or several files to the queue of downloads.
 * //from   w ww  .  j a  va 2  s .c o m
 * New downloads 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.
 */
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (!intent.hasExtra(EXTRA_ACCOUNT) || !intent.hasExtra(EXTRA_FILE)
    /*!intent.hasExtra(EXTRA_FILE_PATH) ||
    !intent.hasExtra(EXTRA_REMOTE_PATH)*/
    ) {
        Log_OC.e(TAG, "Not enough information provided in intent");
        return START_NOT_STICKY;
    }
    Account account = intent.getParcelableExtra(EXTRA_ACCOUNT);
    OCFile file = intent.getParcelableExtra(EXTRA_FILE);

    AbstractList<String> requestedDownloads = new Vector<String>(); // dvelasco: now this always contains just one element, but that can change in a near future (download of multiple selection)
    String downloadKey = buildRemoteName(account, file);
    try {
        DownloadFileOperation newDownload = new DownloadFileOperation(account, file);
        mPendingDownloads.putIfAbsent(downloadKey, newDownload);
        newDownload.addDatatransferProgressListener(this);
        newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder);
        requestedDownloads.add(downloadKey);
        sendBroadcastNewDownload(newDownload);

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

    if (requestedDownloads.size() > 0) {
        Message msg = mServiceHandler.obtainMessage();
        msg.arg1 = startId;
        msg.obj = requestedDownloads;
        mServiceHandler.sendMessage(msg);
    }

    return START_NOT_STICKY;
}

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

/**
 * Handle incoming intents. Do not load a product if we already have one.
 */// w w w .java2s  . 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.google.android.apps.iosched.ui.AccountActivity.java

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

    setContentView(R.layout.activity_letterboxed_when_large);

    final Intent intent = getIntent();
    if (intent.hasExtra(EXTRA_FINISH_INTENT)) {
        mFinishIntent = intent.getParcelableExtra(EXTRA_FINISH_INTENT);
    }/*from w w w  .  ja  va  2  s .  c o  m*/

    if (savedInstanceState == null) {
        if (!AccountUtils.isAuthenticated(this)) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.root_container, new SignInMainFragment(), "signin_main").commit();
        } else {
            mChosenAccount = new Account(AccountUtils.getChosenAccountName(this), "com.google");
            getSupportFragmentManager().beginTransaction().add(R.id.root_container,
                    SignInSetupFragment.makeFragment(SETUP_ATTENDEE), "setup_attendee").commit();
        }
    } else {
        String accountName = savedInstanceState.getString(KEY_CHOSEN_ACCOUNT);
        if (accountName != null) {
            mChosenAccount = new Account(accountName, "com.google");
            mPlusClient = (new PlusClient.Builder(this, this, this)).setAccountName(accountName)
                    .setScopes(AccountUtils.AUTH_SCOPES).build();
        }
    }
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.AccountActivity.java

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

    setContentView(R.layout.activity_letterboxed_when_large);

    final Intent intent = getIntent();
    if (intent.hasExtra(EXTRA_FINISH_INTENT)) {
        mFinishIntent = intent.getParcelableExtra(EXTRA_FINISH_INTENT);
    }//from  w ww .ja v a 2s . c o m

    if (savedInstanceState == null) {
        if (!AccountUtils.isAuthenticated(this)) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.root_container, new SignInMainFragment(), "signin_main").commit();
        } else {
            mChosenAccount = new Account(AccountUtils.getChosenAccountName(this), "com.google");
            getSupportFragmentManager().beginTransaction().add(R.id.root_container,
                    SignInSetupFragment.makeFragment(SETUP_ATTENDEE), "setup_attendee").commit();
        }
    } else {
        String accountName = savedInstanceState.getString(KEY_CHOSEN_ACCOUNT);
        if (accountName != null) {
            mChosenAccount = new Account(accountName, "com.google");
            //     mPlusClient = (new PlusClient.Builder(this, this, this))
            //             .setAccountName(accountName)
            //             .setScopes(AccountUtils.AUTH_SCOPES)
            //            .build();
        }
    }
}

From source file:de.janniskilian.xkcdreader.presentation.components.showcomics.ShowComicsActivity.java

private void handleIntent(Intent intent) {
    if (intent.hasExtra("num")) {
        presenter.onComicSelected(intent.getIntExtra("num", 1));
        intent.removeExtra("num");
    }//from w  w w  .  j a  v a  2s  . c om
}