List of usage examples for android.content Intent getScheme
public @Nullable String getScheme()
From source file:com.fanfou.app.opensource.util.IntentHelper.java
public static void logIntent(final String tag, final Intent intent) { if (intent == null) { return;/* w w w. ja v a 2 s. c om*/ } final StringBuffer sb = new StringBuffer(); sb.append("\nAction:" + intent.getAction()); sb.append("\nData:" + intent.getData()); sb.append("\nDataStr:" + intent.getDataString()); sb.append("\nScheme:" + intent.getScheme()); sb.append("\nType:" + intent.getType()); final Bundle extras = intent.getExtras(); if ((extras != null) && !extras.isEmpty()) { for (final String key : extras.keySet()) { final Object value = extras.get(key); sb.append("\nEXTRA: {" + key + "::" + value + "}"); } } else { sb.append("\nNO EXTRAS"); } Log.i(tag, sb.toString()); }
From source file:dev.drsoran.moloko.fragments.factories.AbstractIntentFragmentFactory.java
protected final static Fragment resolveIntentToFragment(Context context, Intent intent, List<Class<? extends Fragment>> fragmentClasses) { Fragment fragment = null;//w w w .j a va 2 s. co m try { for (Iterator<Class<? extends Fragment>> i = fragmentClasses.iterator(); i.hasNext() && fragment == null;) { final Class<? extends Fragment> entry = i.next(); final IntentFilter filter = (IntentFilter) entry.getMethod("getIntentFilter").invoke(null); if (filter.matchAction(intent.getAction()) && filter.matchData(intent.resolveType(context), intent.getScheme(), intent.getData()) > 0) { fragment = DefaultFragmentFactory.create(context, entry, intent.getExtras()); } } } catch (Throwable e) { MolokoApp.Log.e(AbstractIntentFragmentFactory.class, "Unable to instantiate new fragment by Intent " + intent, e); } return fragment; }
From source file:bolts.MeasurementEvent.java
private static Bundle getApplinkLogData(Context context, String eventName, Bundle appLinkData, Intent applinkIntent) { Bundle logData = new Bundle(); ComponentName resolvedActivity = applinkIntent.resolveActivity(context.getPackageManager()); if (resolvedActivity != null) { logData.putString("class", resolvedActivity.getShortClassName()); }// ww w. j av a2 s. com if (APP_LINK_NAVIGATE_OUT_EVENT_NAME.equals(eventName)) { if (resolvedActivity != null) { logData.putString("package", resolvedActivity.getPackageName()); } if (applinkIntent.getData() != null) { logData.putString("outputURL", applinkIntent.getData().toString()); } if (applinkIntent.getScheme() != null) { logData.putString("outputURLScheme", applinkIntent.getScheme()); } } else if (APP_LINK_NAVIGATE_IN_EVENT_NAME.equals(eventName)) { if (applinkIntent.getData() != null) { logData.putString("inputURL", applinkIntent.getData().toString()); } if (applinkIntent.getScheme() != null) { logData.putString("inputURLScheme", applinkIntent.getScheme()); } } for (String key : appLinkData.keySet()) { Object o = appLinkData.get(key); if (o instanceof Bundle) { for (String subKey : ((Bundle) o).keySet()) { String logValue = objectToJSONString(((Bundle) o).get(subKey)); if (key.equals("referer_app_link")) { if (subKey.equalsIgnoreCase("url")) { logData.putString("refererURL", logValue); continue; } else if (subKey.equalsIgnoreCase("app_name")) { logData.putString("refererAppName", logValue); continue; } else if (subKey.equalsIgnoreCase("package")) { logData.putString("sourceApplication", logValue); continue; } } logData.putString(key + "/" + subKey, logValue); } } else { String logValue = objectToJSONString(o); if (key.equals("target_url")) { Uri targetURI = Uri.parse(logValue); logData.putString("targetURL", targetURI.toString()); logData.putString("targetURLHost", targetURI.getHost()); continue; } logData.putString(key, logValue); } } return logData; }
From source file:com.barryku.android.boxnet.AuthActivity.java
/** Called when the activity is first created. */ @Override/*from w w w .ja v a2 s . co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Intent intent = getIntent(); if (BOX_INTENT_SCHEME.equals(intent.getScheme())) { Uri uri = intent.getData(); Log.d(LOG_TAG, "processing auth callback: " + uri); String authToken = uri.getQueryParameter("auth_token"); if (authToken != null) { SharedPreferences.Editor editor = prefs.edit(); editor.putString(AUTH_TOKEN_KEY, authToken); editor.commit(); } } Button login = (Button) findViewById(R.id.btnLogin); login.setOnClickListener(new OnClickListener() { public void onClick(View v) { String requestToken = getRequestToken(); Log.d(LOG_TAG, requestToken); Intent authIntent = new Intent("android.intent.action.VIEW", Uri.parse(getString(R.string.auth_uri) + requestToken)); startActivity(authIntent); } private String getRequestToken() { RestTemplate restTemplate = RestUtil.getRestTemplate(); RequestToken resp = restTemplate.getForObject(getString(R.string.request_uri), RequestToken.class, getString(R.string.api_key)); return resp.getRequestToken(); } }); }
From source file:com.jiramot.foursquare.android.FSAPITest.java
private void init(Intent intent) { if (intent.getScheme() == null) { foursquare = new Foursquare(client, "fsapitest://connect"); foursquare.authorize(this, new FoursquareAuthenDialogListener()); }/*from w ww. j a v a2 s . c o m*/ }
From source file:org.sufficientlysecure.keychain.ui.QrCodeScanActivity.java
protected void handleActions(Intent intent) { String action = intent.getAction(); Uri dataUri = intent.getData();/*from w ww .ja v a 2 s . com*/ String scheme = intent.getScheme(); if (scheme != null && scheme.toLowerCase(Locale.ENGLISH).equals(Constants.FINGERPRINT_SCHEME)) { // Scanning a fingerprint directly with Barcode Scanner, thus we already have scanned returnResult = false; startCertify(dataUri); } else if (ACTION_SCAN_WITH_RESULT.equals(action)) { // scan using xzing's Barcode Scanner and return result parcel in OpenKeychain returnResult = true; new IntentIntegrator(this).initiateScan(); } else if (ACTION_QR_CODE_API.equals(action)) { // scan using xzing's Barcode Scanner from outside OpenKeychain returnResult = false; new IntentIntegrator(this).initiateScan(); } else { Log.e(Constants.TAG, "No valid scheme or action given!"); finish(); } }
From source file:org.sufficientlysecure.keychain.ui.ImportKeysProxyActivity.java
protected void handleActions(Intent intent) { String action = intent.getAction(); Uri dataUri = intent.getData();/* w w w . j a v a 2s. c o m*/ String scheme = intent.getScheme(); if (scheme != null && scheme.toLowerCase(Locale.ENGLISH).equals(Constants.FINGERPRINT_SCHEME)) { // Scanning a fingerprint directly with Barcode Scanner, thus we already have scanned processScannedContent(dataUri); } else if (ACTION_SCAN_WITH_RESULT.equals(action) || ACTION_SCAN_IMPORT.equals(action) || ACTION_QR_CODE_API.equals(action)) { new IntentIntegrator(this).setCaptureActivity(QrCodeCaptureActivity.class).initiateScan(); } else if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) { // Check to see if the Activity started due to an Android Beam if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { handleActionNdefDiscovered(getIntent()); } else { Log.e(Constants.TAG, "Android Beam not supported by Android < 4.1"); finish(); } } else { Log.e(Constants.TAG, "No valid scheme or action given!"); finish(); } }
From source file:net.xisberto.work_schedule.MainActivity.java
private boolean shouldSetPeriod(Intent intent) { return (intent.getAction() != null && intent.getAction().equals(ACTION_SET_PERIOD)) || (intent.getScheme() != null && intent.getScheme().equals("work_schedule")); }
From source file:com.miqtech.master.client.ui.StartActivity.java
/** * ?href//from w w w . j a v a 2 s . c om */ private void getHref() { Intent intent = getIntent(); String scheme = intent.getScheme(); Uri uri = intent.getData(); System.out.println("scheme:" + scheme); if (uri != null) { String dataString = intent.getDataString(); } }
From source file:info.guardianproject.otr.app.im.app.AddContactActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mApp = (ImApp) getApplication();// w w w . j a v a 2 s. c o m mApp.setAppTheme(this); mHandler = new SimpleAlertHandler(this); setContentView(R.layout.add_contact_activity); BrandingResources brandingRes = mApp.getBrandingResource(0); setTitle(brandingRes.getString(BrandingResourceIDs.STRING_ADD_CONTACT_TITLE)); TextView label = (TextView) findViewById(R.id.input_contact_label); label.setText(brandingRes.getString(BrandingResourceIDs.STRING_LABEL_INPUT_CONTACT)); mAddressList = (MultiAutoCompleteTextView) findViewById(R.id.email); mAddressList.setTokenizer(new Rfc822Tokenizer()); mAddressList.addTextChangedListener(mTextWatcher); mListSpinner = (Spinner) findViewById(R.id.choose_list); setupAccountSpinner(); mInviteButton = (Button) findViewById(R.id.invite); mInviteButton.setText(brandingRes.getString(BrandingResourceIDs.STRING_BUTTON_ADD_CONTACT)); mInviteButton.setOnClickListener(mButtonHandler); mInviteButton.setEnabled(false); mScanButton = (Button) findViewById(R.id.scan); mScanButton.setOnClickListener(mScanHandler); Intent intent = getIntent(); String scheme = intent.getScheme(); if (TextUtils.equals(scheme, "xmpp")) { addContactFromUri(intent.getData()); } }