Java Code Examples for android.content.Intent#getExtra()

The following examples show how to use android.content.Intent#getExtra() . 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: Vpn.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    if (!mEnableTeardown) return;

    if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
        if (intent.getIntExtra(ConnectivityManager.EXTRA_NETWORK_TYPE,
                ConnectivityManager.TYPE_NONE) == mOuterConnection.get()) {
            NetworkInfo info = (NetworkInfo)intent.getExtra(
                    ConnectivityManager.EXTRA_NETWORK_INFO);
            if (info != null && !info.isConnectedOrConnecting()) {
                try {
                    mObserver.interfaceStatusChanged(mOuterInterface, false);
                } catch (RemoteException e) {}
            }
        }
    }
}
 
Example 2
Source File: AlarmReceiver.java    From product-emm with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
	if (Constants.DEBUG_MODE_ENABLED) {
		Log.d(TAG, "Recurring alarm; requesting alarm service.");
	}

	if (intent.hasExtra(context.getResources().getString(R.string.alarm_scheduled_operation))) {
		String operationCode = intent.getStringExtra(context.getResources().getString(R.string.alarm_scheduled_operation));
		ApplicationManager applicationManager = new ApplicationManager(context.getApplicationContext());
		if(operationCode != null && operationCode.trim().equals(Constants.Operation.INSTALL_APPLICATION)) {
			String appUrl = intent.getStringExtra(context.getResources().getString(R.string.app_url));
			Operation operation = null;
			if (intent.hasExtra(context.getResources().getString(R.string.alarm_scheduled_operation_payload)))				{
				operation = (Operation) intent.getExtra(context.getResources().getString(R.string.alarm_scheduled_operation_payload));
			}
			applicationManager.installApp(appUrl, null, operation);
		} else if(operationCode != null && operationCode.trim().equals(Constants.Operation.UNINSTALL_APPLICATION)) {
			String packageUri = intent.getStringExtra(context.getResources().getString(R.string.app_uri));
			applicationManager.uninstallApplication(packageUri, null);
		}

	} else {
		OperationTask operationTask = new OperationTask();
		operationTask.execute(context);
	}

}
 
Example 3
Source File: MediaPlayer.java    From droidel with Apache License 2.0 5 votes vote down vote up
private void handleProxyBroadcast(Intent intent) {
    ProxyProperties props =
        (ProxyProperties)intent.getExtra(Proxy.EXTRA_PROXY_INFO);

    if (props == null || props.getHost() == null) {
        updateProxyConfig(null);
    } else {
        updateProxyConfig(props);
    }
}