Java Code Examples for android.app.Activity#unbindService()

The following examples show how to use android.app.Activity#unbindService() . 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: Browser.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public static void unbindCustomTabsService(Activity activity) {
    if (customTabsServiceConnection == null) {
        return;
    }
    Activity currentActivity = currentCustomTabsActivity == null ? null : currentCustomTabsActivity.get();
    if (currentActivity == activity) {
        currentCustomTabsActivity.clear();
    }
    try {
        activity.unbindService(customTabsServiceConnection);
    } catch (Exception ignore) {

    }
    customTabsClient = null;
    customTabsSession = null;
}
 
Example 2
Source File: Browser.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static void unbindCustomTabsService(Activity activity) {
    if (customTabsServiceConnection == null) {
        return;
    }
    Activity currentActivity = currentCustomTabsActivity == null ? null : currentCustomTabsActivity.get();
    if (currentActivity == activity) {
        currentCustomTabsActivity.clear();
    }
    try {
        activity.unbindService(customTabsServiceConnection);
    } catch (Exception ignore) {

    }
    customTabsClient = null;
    customTabsSession = null;
}
 
Example 3
Source File: Browser.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public static void unbindCustomTabsService(Activity activity) {
    if (customTabsServiceConnection == null) {
        return;
    }
    Activity currentActivity = currentCustomTabsActivity == null ? null : currentCustomTabsActivity.get();
    if (currentActivity == activity) {
        currentCustomTabsActivity.clear();
    }
    try {
        activity.unbindService(customTabsServiceConnection);
    } catch (Exception ignore) {

    }
    customTabsClient = null;
    customTabsSession = null;
}
 
Example 4
Source File: AppListFragment.java    From island with Apache License 2.0 5 votes vote down vote up
@Override public void onDestroyView() {
	if (mIslandManagerConnection != null) {
		final Activity activity = getActivity();
		if (activity != null) activity.unbindService(mIslandManagerConnection);
		mIslandManagerConnection = null;
	}
	super.onDestroyView();
}
 
Example 5
Source File: CustomTabServiceHelper.java    From cordova-plugin-safariviewcontroller with MIT License 5 votes vote down vote up
/**
 * Unbinds the Activity from the Custom Tabs Service.
 * @param activity the activity that is connected to the service.
 */
public boolean unbindCustomTabsService(Activity activity) {
    if (mConnection == null) return false;
    activity.unbindService(mConnection);
    mClient = null;
    mCustomTabsSession = null;
    mConnection = null;
    return true;
}
 
Example 6
Source File: ChromeCustomTabsHelper.java    From Hews with MIT License 5 votes vote down vote up
/**
 * Unbinds the Activity from the Custom Tabs Service
 *
 * @param activity the activity that is connected to the service
 */
public void unbindCustomTabsService(Activity activity) {
    if (mConnection == null) return;
    activity.unbindService(mConnection);
    mCustomTabsClient = null;
    mCustomTabsSession = null;
}
 
Example 7
Source File: CustomTabsHelper.java    From rides-android-sdk with MIT License 5 votes vote down vote up
/**
 * Called to clean up the CustomTab when the parentActivity is destroyed.
 */
public void onDestroy(Activity parentActivity) {
    if (connection != null) {
        parentActivity.unbindService(connection);
        connection = null;
    }
}
 
Example 8
Source File: BackgroundMode.java    From cordova-plugin-background-mode with Apache License 2.0 5 votes vote down vote up
/**
 * Bind the activity to a background service and put them into foreground
 * state.
 */
private void stopService()
{
    Activity context = cordova.getActivity();
    Intent intent    = new Intent(context, ForegroundService.class);

    if (!isBind) return;

    fireEvent(Event.DEACTIVATE, null);
    context.unbindService(connection);
    context.stopService(intent);

    isBind = false;
}
 
Example 9
Source File: CustomTabActivityHelper.java    From custom-tabs-client with Apache License 2.0 5 votes vote down vote up
/**
 * Unbinds the Activity from the Custom Tabs Service.
 * @param activity the activity that is connected to the service.
 */
public void unbindCustomTabsService(Activity activity) {
    if (mConnection == null) return;
    activity.unbindService(mConnection);
    mClient = null;
    mCustomTabsSession = null;
    mConnection = null;
}
 
Example 10
Source File: CustomTabsDelegate.java    From materialistic with Apache License 2.0 5 votes vote down vote up
/**
 * Unbinds the Activity from the Custom Tabs Service.
 *
 * @param activity the activity that is connected to the service.
 */
void unbindCustomTabsService(Activity activity) {
    if (mConnection == null) {
        return;
    }
    activity.unbindService(mConnection);
    mClient = null;
    mCustomTabsSession = null;
    mConnection = null;
}
 
Example 11
Source File: CustomTabActivityHelper.java    From droidddle with Apache License 2.0 5 votes vote down vote up
/**
 * Unbinds the Activity from the Custom Tabs Service
 *
 * @param activity the activity that is connected to the service
 */
public void unbindCustomTabsService(Activity activity) {
    if (mConnection == null) return;
    activity.unbindService(mConnection);
    mClient = null;
    mCustomTabsSession = null;
}
 
Example 12
Source File: CustomTabActivityHelper.java    From Focus with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Unbinds the Activity from the Custom Tabs Service.
 * @param activity the activity that is connected to the service.
 */
public void unbindCustomTabsService(Activity activity) {
    if (mConnection == null) return;
    activity.unbindService(mConnection);
    mClient = null;
    mCustomTabsSession = null;
    mConnection = null;
}
 
Example 13
Source File: CustomTabActivityHelper.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
/**
 * Unbinds the Activity from the Custom Tabs Service
 * @param activity the activity that is bound to the service
 */
public void unbindCustomTabsService(Activity activity) {
    if (mConnection == null) return;
    activity.unbindService(mConnection);
    mClient = null;
    mCustomTabsSession = null;
}
 
Example 14
Source File: CustomTabActivityHelper.java    From MaterialHome with Apache License 2.0 5 votes vote down vote up
/**
 * Unbinds the Activity from the Custom Tabs Service
 *
 * @param activity the activity that is bound to the service
 */
public void unbindCustomTabsService(Activity activity) {
    if (mConnection == null) return;
    activity.unbindService(mConnection);
    mClient = null;
    mCustomTabsSession = null;
}
 
Example 15
Source File: CustomTabActivityHelper.java    From AndroidProjects with MIT License 5 votes vote down vote up
/**
 * Unbinds the Activity from the Custom Tabs Service.
 *
 * @param activity the activity that is connected to the service.
 */
public void unbindCustomTabsService(Activity activity) {
    if (mConnection == null) return;
    activity.unbindService(mConnection);
    mClient = null;
    mCustomTabsSession = null;
    mConnection = null;
}
 
Example 16
Source File: SensonListener.java    From LLApp with Apache License 2.0 5 votes vote down vote up
public void stopService(Activity activity){
    //暂停服务
    Intent intent = new Intent(activity, AidlService.class);
    activity.stopService(intent);

    //断开与远程Service的连接
    activity.unbindService(sc);
}
 
Example 17
Source File: CustomTabActivityHelper.java    From materialup with Apache License 2.0 5 votes vote down vote up
/**
 * Unbinds the Activity from the Custom Tabs Service
 *
 * @param activity the activity that is bound to the service
 */
public void unbindCustomTabsService(Activity activity) {
    if (mConnection == null) return;
    activity.unbindService(mConnection);
    mClient = null;
    mCustomTabsSession = null;
}
 
Example 18
Source File: CustomTabActivityHelper.java    From Focus with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Unbinds the Activity from the Custom Tabs Service.
 * @param activity the activity that is connected to the service.
 */
public void unbindCustomTabsService(Activity activity) {
    if (mConnection == null) return;
    activity.unbindService(mConnection);
    mClient = null;
    mCustomTabsSession = null;
    mConnection = null;
}
 
Example 19
Source File: CustomTabActivityHelper.java    From android-browser-helper with Apache License 2.0 5 votes vote down vote up
/**
 * Unbinds the Activity from the Custom Tabs Service.
 * @param activity the activity that is connected to the service.
 */
public void unbindCustomTabsService(Activity activity) {
    if (mConnection == null) return;
    activity.unbindService(mConnection);
    mClient = null;
    mCustomTabsSession = null;
    mConnection = null;
}
 
Example 20
Source File: UpdateFragment.java    From Android-nRF-Beacon with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void onReceive(final Context context, final Intent intent) {
	final Activity activity = getActivity();
	if (activity == null || !isResumed())
		return;

	final String action = intent.getAction();

	if (UpdateService.ACTION_STATE_CHANGED.equals(action)) {
		final int state = intent.getIntExtra(UpdateService.EXTRA_DATA, UpdateService.STATE_DISCONNECTED);

		switch (state) {
		case UpdateService.STATE_DISCONNECTED:
			mConnectButton.setText(R.string.action_connect);
			mConnectButton.setEnabled(true);
			setUuidControlsEnabled(false);
			setMajorMinorControlsEnabled(false);
			setRssiControlsEnabled(false);
			setManufacturerIdControlsEnabled(false);
			setAdvIntervalControlsEnabled(false);
			setLedControlsEnabled(false);
			mAdvancedTitleView.setEnabled(true);

			final Intent service = new Intent(activity, UpdateService.class);
			activity.unbindService(mServiceConnection);
			activity.stopService(service);
			mBinder = null;
			mBinded = false;
			break;
		case UpdateService.STATE_CONNECTED:
			mConnectButton.setText(R.string.action_disconnect);
			mConnectButton.setEnabled(true);
			break;
		case UpdateService.STATE_DISCONNECTING:
		case UpdateService.STATE_CONNECTING:
			mConnectButton.setEnabled(false);
			break;
		}
	} else if (UpdateService.ACTION_UUID_READY.equals(action)) {
		final UUID uuid = ((ParcelUuid) intent.getParcelableExtra(UpdateService.EXTRA_DATA)).getUuid();
		mUuidView.setText(uuid.toString());
		setUuidControlsEnabled(true);
	} else if (UpdateService.ACTION_MAJOR_MINOR_READY.equals(action)) {
		final int major = intent.getIntExtra(UpdateService.EXTRA_MAJOR, 0);
		final int minor = intent.getIntExtra(UpdateService.EXTRA_MINOR, 0);
		mMajorView.setText(String.valueOf(major));
		mMinorView.setText(String.valueOf(minor));
		setMajorMinorControlsEnabled(true);
	} else if (UpdateService.ACTION_RSSI_READY.equals(action)) {
		final int rssi = intent.getIntExtra(UpdateService.EXTRA_DATA, 0);
		mCalibratedRssiView.setTag(rssi);
		mCalibratedRssiView.setText(String.valueOf(rssi));
		setRssiControlsEnabled(true);
	} else if (UpdateService.ACTION_MANUFACTURER_ID_READY.equals(action)) {
		final int manufacturerId = intent.getIntExtra(UpdateService.EXTRA_DATA, 0);
		mManufacturerIdView.setText(String.valueOf(manufacturerId));
		setManufacturerIdControlsEnabled(true);
	} else if (UpdateService.ACTION_ADV_INTERVAL_READY.equals(action)) {
		final int interval = intent.getIntExtra(UpdateService.EXTRA_DATA, 0);
		mAdvIntervalView.setText(String.valueOf(interval));
		setAdvIntervalControlsEnabled(true);
	} else if (UpdateService.ACTION_LED_STATUS_READY.equals(action)) {
		final boolean on = intent.getBooleanExtra(UpdateService.EXTRA_DATA, false);
		mLedSwitchActionDisabled = true;
		mLedsSwitch.setChecked(on);
		mLedSwitchActionDisabled = false;
		setLedControlsEnabled(true);
	} else if (UpdateService.ACTION_DONE.equals(action)) {
		final boolean advanced = intent.getBooleanExtra(UpdateService.EXTRA_DATA, false);
		mAdvancedTitleView.setEnabled(advanced);
		mBinder.read();
	} else if (UpdateService.ACTION_GATT_ERROR.equals(action)) {
		final int error = intent.getIntExtra(UpdateService.EXTRA_DATA, 0);

		switch (error) {
		case UpdateService.ERROR_UNSUPPORTED_DEVICE:
			Toast.makeText(activity, R.string.update_error_device_not_supported, Toast.LENGTH_SHORT).show();
			break;
		default:
			Toast.makeText(activity, getString(R.string.update_error_other, error), Toast.LENGTH_SHORT).show();
			break;
		}
		mBinder.disconnectAndClose();
	}
}