Java Code Examples for android.app.Activity#RESULT_FIRST_USER

The following examples show how to use android.app.Activity#RESULT_FIRST_USER . 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: HubConnectivityAndPowerFragment.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    boolean requestCodeMatches = requestCode == IntentRequestCode.HUB_WIFI_PAIRING_REQUEST.requestCode;
    boolean successfulResult = resultCode == Activity.RESULT_OK;
    justSetupWiFi = requestCodeMatches && successfulResult;

    if (justSetupWiFi) {
        setWifiButtonDescriptionText(true, false);
        Activity activity = getActivity();
        if (data == null || !(activity instanceof PermissionsActivity)) {
            return; // Can't show snackbar!
        }

        String network = data.getStringExtra(Intent.EXTRA_TEXT);
        justSetupWiFi = data.getBooleanExtra(Intent.EXTRA_RETURN_RESULT, true);
        final String networkName = network == null ? "" : network;
        ((PermissionsActivity) activity).showSnackbar(layout -> ConnectedToWiFiSnackBar.make(layout).setNetworkName(networkName, justSetupWiFi));
    } else if (resultCode == Activity.RESULT_FIRST_USER) {
        ScleraPopup.newInstance(
                R.string.device_is_offline,
                R.string.device_is_offline_sub_text,
                R.string.ok,
                R.string.cancel,
                true,
                true
        ).show(getFragmentManager());
    }
}
 
Example 2
Source File: PDFFragment.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
	switch (requestCode) {
		case Constants.OUTLINE_REQUEST_CODE:
			if (resultCode >= Activity.RESULT_FIRST_USER) {
				mDocView.pushHistory();
				mDocView.setDisplayedViewIndex(resultCode - Activity.RESULT_FIRST_USER);
			}
			break;
	}
	super.onActivityResult(requestCode, resultCode, data);
}
 
Example 3
Source File: LinphoneActivity.java    From Linphone4Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	if (resultCode == Activity.RESULT_FIRST_USER && requestCode == SETTINGS_ACTIVITY) {
		if (data.getExtras().getBoolean("Exit", false)) {
			quit();
		} else {
			pendingFragmentTransaction = (FragmentsAvailable) data.getExtras().getSerializable("FragmentToDisplay");
		}
	} else if (resultCode == Activity.RESULT_FIRST_USER && requestCode == CALL_ACTIVITY) {
		getIntent().putExtra("PreviousActivity", CALL_ACTIVITY);
		callTransfer = data == null ? false : data.getBooleanExtra("Transfer", false);
		boolean chat = data == null ? false : data.getBooleanExtra("chat", false);
		if(chat){
			pendingFragmentTransaction = FragmentsAvailable.CHAT_LIST;
		}
		if (LinphoneManager.getLc().getCallsNb() > 0) {
			initInCallMenuLayout(callTransfer);
		} else {
			resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
		}
	} else if (requestCode == PERMISSIONS_REQUEST_OVERLAY) {
		if (Compatibility.canDrawOverlays(this)) {
			LinphonePreferences.instance().enableOverlay(true);
		}
	} else {
		super.onActivityResult(requestCode, resultCode, data);
	}
}
 
Example 4
Source File: DefaultInstallerActivity.java    From fdroidclient with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE_INSTALL:
            switch (resultCode) {
                case Activity.RESULT_OK:
                    installer.sendBroadcastInstall(canonicalUri,
                            Installer.ACTION_INSTALL_COMPLETE);
                    break;
                case Activity.RESULT_CANCELED:
                    installer.sendBroadcastInstall(canonicalUri,
                            Installer.ACTION_INSTALL_INTERRUPTED);
                    break;
                case Activity.RESULT_FIRST_USER:
                default:
                    // AOSP returns Activity.RESULT_FIRST_USER on error
                    installer.sendBroadcastInstall(canonicalUri,
                            Installer.ACTION_INSTALL_INTERRUPTED,
                            getString(R.string.install_error_unknown));
                    break;
            }

            break;
        case REQUEST_CODE_UNINSTALL:
            switch (resultCode) {
                case Activity.RESULT_OK:
                    installer.sendBroadcastUninstall(Installer.ACTION_UNINSTALL_COMPLETE);
                    break;
                case Activity.RESULT_CANCELED:
                    installer.sendBroadcastUninstall(Installer.ACTION_UNINSTALL_INTERRUPTED);
                    break;
                case Activity.RESULT_FIRST_USER:
                default:
                    // AOSP UninstallAppProgress returns RESULT_FIRST_USER on error
                    installer.sendBroadcastUninstall(Installer.ACTION_UNINSTALL_INTERRUPTED,
                            getString(R.string.uninstall_error_unknown));
                    break;
            }

            break;
        default:
            throw new RuntimeException("Invalid request code!");
    }

    // after doing the broadcasts, finish this transparent wrapper activity
    finish();
}