Example usage for android.bluetooth BluetoothAdapter EXTRA_DISCOVERABLE_DURATION

List of usage examples for android.bluetooth BluetoothAdapter EXTRA_DISCOVERABLE_DURATION

Introduction

In this page you can find the example usage for android.bluetooth BluetoothAdapter EXTRA_DISCOVERABLE_DURATION.

Prototype

String EXTRA_DISCOVERABLE_DURATION

To view the source code for android.bluetooth BluetoothAdapter EXTRA_DISCOVERABLE_DURATION.

Click Source Link

Document

Used as an optional int extra field in #ACTION_REQUEST_DISCOVERABLE intents to request a specific duration for discoverability in seconds.

Usage

From source file:com.jtechme.apphub.AppDetailsData.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case android.R.id.home:
        if (getIntent().hasExtra(EXTRA_HINT_SEARCHING)) {
            finish();// www.  ja v  a 2s.  c  o  m
        } else {
            navigateUp();
        }
        return true;

    case LAUNCH:
        launchApk(app.packageName);
        return true;

    case SHARE:
        shareApp(app);
        return true;

    case INSTALL:
        // Note that this handles updating as well as installing.
        if (app.suggestedVercode > 0) {
            final Apk apkToInstall = ApkProvider.Helper.find(this, app.packageName, app.suggestedVercode);
            install(apkToInstall);
        }
        return true;

    case UNINSTALL:
        removeApk(app.packageName);
        return true;

    case IGNOREALL:
        app.ignoreAllUpdates ^= true;
        item.setChecked(app.ignoreAllUpdates);
        return true;

    case IGNORETHIS:
        if (app.ignoreThisUpdate >= app.suggestedVercode)
            app.ignoreThisUpdate = 0;
        else
            app.ignoreThisUpdate = app.suggestedVercode;
        item.setChecked(app.ignoreThisUpdate > 0);
        return true;

    case SEND_VIA_BLUETOOTH:
        /*
         * If Bluetooth has not been enabled/turned on, then
         * enabling device discoverability will automatically enable Bluetooth
         */
        Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
        startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
        // if this is successful, the Bluetooth transfer is started
        return true;

    }
    return super.onOptionsItemSelected(item);
}

From source file:org.fdroid.fdroid.AppDetails.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case android.R.id.home:
        if (getIntent().hasExtra(EXTRA_HINT_SEARCHING)) {
            finish();//w w  w  .  j  a  va  2s .c  o m
        } else {
            navigateUp();
        }
        return true;

    case LAUNCH:
        launchApk(app.packageName);
        return true;

    case SHARE:
        shareApp(app);
        return true;

    case INSTALL:
        // Note that this handles updating as well as installing.
        if (app.suggestedVersionCode > 0) {
            final Apk apkToInstall = ApkProvider.Helper.find(this, app.packageName, app.suggestedVersionCode);
            install(apkToInstall);
        }
        return true;

    case UNINSTALL:
        removeApk(app.packageName);
        return true;

    case IGNOREALL:
        app.ignoreAllUpdates ^= true;
        item.setChecked(app.ignoreAllUpdates);
        return true;

    case IGNORETHIS:
        if (app.ignoreThisUpdate >= app.suggestedVersionCode) {
            app.ignoreThisUpdate = 0;
        } else {
            app.ignoreThisUpdate = app.suggestedVersionCode;
        }
        item.setChecked(app.ignoreThisUpdate > 0);
        return true;

    case SEND_VIA_BLUETOOTH:
        /*
         * If Bluetooth has not been enabled/turned on, then
         * enabling device discoverability will automatically enable Bluetooth
         */
        Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
        startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
        // if this is successful, the Bluetooth transfer is started
        return true;

    }
    return super.onOptionsItemSelected(item);
}

From source file:id.ridon.keude.AppDetailsData.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;

    case LAUNCH://ww w.  j ava2s  .  com
        launchApk(app.id);
        return true;

    case SHARE:
        shareApp(app);
        return true;

    case INSTALL:
        // Note that this handles updating as well as installing.
        if (app.suggestedVercode > 0) {
            final Apk apkToInstall = ApkProvider.Helper.find(this, app.id, app.suggestedVercode);
            install(apkToInstall);
        }
        return true;

    case UNINSTALL:
        removeApk(app.id);
        return true;

    case IGNOREALL:
        app.ignoreAllUpdates ^= true;
        item.setChecked(app.ignoreAllUpdates);
        return true;

    case IGNORETHIS:
        if (app.ignoreThisUpdate >= app.suggestedVercode)
            app.ignoreThisUpdate = 0;
        else
            app.ignoreThisUpdate = app.suggestedVercode;
        item.setChecked(app.ignoreThisUpdate > 0);
        return true;

    case WEBSITE:
        tryOpenUri(app.webURL);
        return true;

    case ISSUES:
        tryOpenUri(app.trackerURL);
        return true;

    case SOURCE:
        tryOpenUri(app.sourceURL);
        return true;

    case BITCOIN:
        tryOpenUri("bitcoin:" + app.bitcoinAddr);
        return true;

    case LITECOIN:
        tryOpenUri("litecoin:" + app.litecoinAddr);
        return true;

    case DOGECOIN:
        tryOpenUri("dogecoin:" + app.dogecoinAddr);
        return true;

    case FLATTR:
        tryOpenUri("https://flattr.com/thing/" + app.flattrID);
        return true;

    case DONATE_URL:
        tryOpenUri(app.donateURL);
        return true;

    case SEND_VIA_BLUETOOTH:
        /*
         * If Bluetooth has not been enabled/turned on, then
         * enabling device discoverability will automatically enable Bluetooth
         */
        Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
        startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
        // if this is successful, the Bluetooth transfer is started
        return true;

    }
    return super.onOptionsItemSelected(item);
}