Java Code Examples for org.chromium.chrome.browser.physicalweb.PhysicalWeb#startPhysicalWeb()

The following examples show how to use org.chromium.chrome.browser.physicalweb.PhysicalWeb#startPhysicalWeb() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhysicalWebPreferenceFragment.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[],
                                       int[] grantResults) {
    switch (requestCode) {
        case REQUEST_ID:
            if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                PhysicalWebUma.onPrefsLocationGranted(getActivity());
                Log.d(TAG, "Location permission granted");
                PhysicalWeb.startPhysicalWeb(
                        (ChromeApplication) getActivity().getApplicationContext());
            } else {
                PhysicalWebUma.onPrefsLocationDenied(getActivity());
                Log.d(TAG, "Location permission denied");
            }
            break;
        default:
    }
}
 
Example 2
Source File: PhysicalWebPreferenceFragment.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[],
                                       int[] grantResults) {
    switch (requestCode) {
        case REQUEST_ID:
            if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                PhysicalWebUma.onPrefsLocationGranted(getActivity());
                Log.d(TAG, "Location permission granted");
                PhysicalWeb.startPhysicalWeb();
            } else {
                PhysicalWebUma.onPrefsLocationDenied(getActivity());
                Log.d(TAG, "Location permission denied");
            }
            break;
        default:
    }
}
 
Example 3
Source File: PrivacyPreferencesManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the Physical Web preference, which enables background scanning for bluetooth beacons
 * and displays a notification when beacons are found.
 *
 * @param enabled A boolean indicating whether to notify on nearby beacons.
 */
public void setPhysicalWebEnabled(boolean enabled) {
    int state = enabled ? PHYSICAL_WEB_ON : PHYSICAL_WEB_OFF;
    boolean isOnboarding = isPhysicalWebOnboarding();
    mSharedPreferences.edit().putInt(PREF_PHYSICAL_WEB, state).apply();
    if (enabled) {
        if (!isOnboarding) {
            PhysicalWeb.startPhysicalWeb((ChromeApplication) mContext);
        }
    } else {
        PhysicalWeb.stopPhysicalWeb((ChromeApplication) mContext);
    }
}
 
Example 4
Source File: PrivacyPreferencesManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the Physical Web preference, which enables background scanning for bluetooth beacons
 * and displays a notification when beacons are found.
 *
 * @param enabled A boolean indicating whether to notify on nearby beacons.
 */
public void setPhysicalWebEnabled(boolean enabled) {
    int state = enabled ? PHYSICAL_WEB_ON : PHYSICAL_WEB_OFF;
    boolean isOnboarding = isPhysicalWebOnboarding();
    mSharedPreferences.edit().putInt(PREF_PHYSICAL_WEB, state).apply();
    if (enabled) {
        if (!isOnboarding) {
            PhysicalWeb.startPhysicalWeb();
        }
    } else {
        PhysicalWeb.stopPhysicalWeb();
    }
}