List of usage examples for android.content Intent URI_ANDROID_APP_SCHEME
int URI_ANDROID_APP_SCHEME
To view the source code for android.content Intent URI_ANDROID_APP_SCHEME.
Click Source Link
From source file:io.v.android.impl.google.services.beam.BeamActivity.java
@Override public void onResume() { super.onResume(); NdefMessage msgs[] = null;//from w w w .j av a 2s . c o m Intent intent = getIntent(); if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) { Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); if (rawMsgs != null) { msgs = new NdefMessage[rawMsgs.length]; for (int i = 0; i < rawMsgs.length; i++) { msgs[i] = (NdefMessage) rawMsgs[i]; } } } if (msgs == null) { Log.d(TAG, "No ndef messages"); finish(); return; } VBeamManager.Data data = null; for (NdefMessage m : msgs) { data = VBeamManager.decodeMessage(m); if (data != null) break; } if (data == null) { Log.w(TAG, "Unable to deserialize data"); finish(); return; } Log.d(TAG, "connecting to " + data.name); VContext ctx = V.init(this).withTimeout(Duration.standardSeconds(2)); Options opts = new Options(); opts.set(OptionDefs.SERVER_AUTHORIZER, VSecurity.newPublicKeyAuthorizer(data.key)); IntentBeamerClient client = IntentBeamerClientFactory.getIntentBeamerClient(data.name); ListenableFuture<IntentBeamerClient.GetIntentOut> out = client.getIntent(ctx, data.secret, opts); Futures.addCallback(out, new FutureCallback<IntentBeamerClient.GetIntentOut>() { @Override public void onSuccess(IntentBeamerClient.GetIntentOut result) { try { Log.d(TAG, "got intent " + result.intentUri); int flags = 0; if (result.intentUri.startsWith("intent:")) { flags = Intent.URI_INTENT_SCHEME; } else { flags = Intent.URI_ANDROID_APP_SCHEME; } Intent resultIntent = Intent.parseUri(result.intentUri, flags); resultIntent.putExtra(VBeamManager.EXTRA_VBEAM_PAYLOAD, result.payload); startActivity(resultIntent); finish(); } catch (Throwable t) { t.printStackTrace(); } } @Override public void onFailure(Throwable t) { t.printStackTrace(); finish(); } }); }
From source file:io.v.example.vbeam.vbeamexample.MainActivity.java
@Override public ListenableFuture<Pair<String, byte[]>> createIntent(VContext context, ServerCall call) { String blessing = "anonymous"; String[] names = VSecurity.getRemoteBlessingNames(ctx, call.security()); if (names.length > 0) { blessing = names[0];//w w w. java 2s. c o m } byte[] payload = ("Hello " + blessing).getBytes(Charset.forName("utf-8")); Intent intent = new Intent(this, GotBeamActivity.class); intent.setPackage(getApplicationContext().getPackageName()); System.out.println("APP_SCHEME: " + intent.toUri(Intent.URI_ANDROID_APP_SCHEME)); System.out.println("INTENT_SCHEME: " + intent.toUri(Intent.URI_INTENT_SCHEME)); return Futures.immediateFuture(new Pair<>(intent.toUri(Intent.URI_INTENT_SCHEME), payload)); }
From source file:com.irccloud.android.activity.PastebinViewerActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { finish();// w w w .ja v a 2s .com if (getWindowManager().getDefaultDisplay().getWidth() < TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 800, getResources().getDisplayMetrics()) || isMultiWindow()) overridePendingTransition(R.anim.fade_in, R.anim.slide_out_right); return true; } else if (item.getItemId() == R.id.delete) { if (Uri.parse(url).getQueryParameter("own_paste").equals("1")) { AlertDialog.Builder builder = new AlertDialog.Builder(PastebinViewerActivity.this); builder.setTitle("Delete Snippet"); builder.setMessage("Are you sure you want to delete this snippet?"); builder.setPositiveButton("Delete", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { NetworkConnection.getInstance().delete_paste(Uri.parse(url).getQueryParameter("id")); finish(); Toast.makeText(PastebinViewerActivity.this, "Snippet deleted", Toast.LENGTH_SHORT).show(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.cancel(); } }); AlertDialog d = builder.create(); d.setOwnerActivity(PastebinViewerActivity.this); d.show(); } } else if (item.getItemId() == R.id.action_linenumbers) { item.setChecked(!item.isChecked()); mWebView.loadUrl("javascript:window.PASTEVIEW.doToggleLines()"); } else if (item.getItemId() == R.id.action_browser) { if (!PreferenceManager .getDefaultSharedPreferences(IRCCloudApplication.getInstance().getApplicationContext()) .getBoolean("browser", false) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); builder.setToolbarColor(ColorScheme.getInstance().navBarColor); builder.addDefaultShareMenuItem(); builder.addMenuItem("Copy URL", PendingIntent.getBroadcast(this, 0, new Intent(this, ChromeCopyLinkBroadcastReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT)); CustomTabsIntent intent = builder.build(); intent.intent.setData(Uri.parse(url.contains("?") ? url.substring(0, url.indexOf("?")) : url)); if (Build.VERSION.SDK_INT >= 22) intent.intent.putExtra(Intent.EXTRA_REFERRER, Uri.parse(Intent.URI_ANDROID_APP_SCHEME + "//" + getPackageName())); if (Build.VERSION.SDK_INT >= 16 && intent.startAnimationBundle != null) { startActivity(intent.intent, intent.startAnimationBundle); } else { startActivity(intent.intent); } } else { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url.contains("?") ? url.substring(0, url.indexOf("?")) : url)); startActivity(intent); } finish(); return true; } else if (item.getItemId() == R.id.action_copy) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService( CLIPBOARD_SERVICE); if (url.contains("?")) clipboard.setText(url.substring(0, url.indexOf("?"))); else clipboard.setText(url); } else { @SuppressLint("ServiceCast") android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService( CLIPBOARD_SERVICE); android.content.ClipData clip; if (url.contains("?")) clip = android.content.ClipData.newRawUri("IRCCloud Snippet URL", Uri.parse(url.substring(0, url.indexOf("?")))); else clip = android.content.ClipData.newRawUri("IRCCloud Snippet URL", Uri.parse(url)); clipboard.setPrimaryClip(clip); } Toast.makeText(PastebinViewerActivity.this, "Link copied to clipboard", Toast.LENGTH_SHORT).show(); } else if (item.getItemId() == R.id.action_share) { if (getIntent() != null && getIntent().getDataString() != null) { Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse(url)); intent.setType("text/plain"); if (url.contains("?")) intent.putExtra(Intent.EXTRA_TEXT, url.substring(0, url.indexOf("?"))); else intent.putExtra(Intent.EXTRA_TEXT, url); intent.putExtra(ShareCompat.EXTRA_CALLING_PACKAGE, getPackageName()); intent.putExtra(ShareCompat.EXTRA_CALLING_ACTIVITY, getPackageManager().getLaunchIntentForPackage(getPackageName()).getComponent()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(Intent.createChooser(intent, "Share Snippet")); Answers.getInstance().logShare(new ShareEvent().putContentType("Pastebin")); } } else if (item.getItemId() == R.id.action_edit) { mSpinner.setVisibility(View.VISIBLE); Intent i = new Intent(this, PastebinEditorActivity.class); i.putExtra("paste_id", Uri.parse(url).getQueryParameter("id")); startActivityForResult(i, 1); } return super.onOptionsItemSelected(item); }