List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:com.barryku.android.boxnet.AuthActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Log.d(LOG_TAG, "url: " + intent.getData()); }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.editor.ActivityEditor.java
long getNoteId(@NonNull final Intent intent) { long retval = -1; if (intent.getData() != null && (Intent.ACTION_EDIT.equals(intent.getAction()) || Intent.ACTION_VIEW.equals(intent.getAction()))) { if (intent.getData().getPath().startsWith(TaskList.URI.getPath())) { // Find it in the extras. See DashClock extension for an example retval = intent.getLongExtra(Task.TABLE_NAME, -1); } else if ((intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_VISIBLE_NOTES) || intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_NOTES) || intent.getData().getPath().startsWith(Task.URI.getPath()))) { retval = Long.parseLong(intent.getData().getLastPathSegment()); }//from www.ja v a 2 s .c om } return retval; }
From source file:com.ae.apps.common.fragments.ContactPickerFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK && requestCode == CONTACT_PICKER_RESULT) { onContactPicked(data.getData()); } else {// ww w. jav a 2s . c om super.onActivityResult(requestCode, resultCode, data); } }
From source file:me.kartikarora.transfersh.activities.DownloadActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_download); final CoordinatorLayout layout = (CoordinatorLayout) findViewById(R.id.coordinator_layout); Intent intent = getIntent(); url = intent.getData().toString(); name = FilenameUtils.getName(url);/*from w w w . jav a 2s .c o m*/ type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(url)); TransferApplication application = (TransferApplication) getApplication(); mTracker = application.getDefaultTracker(); new AlertDialog.Builder(DownloadActivity.this) .setMessage(getString(R.string.download_file) + " " + getString(R.string.app_name) + "?") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { checkForDownload(name, type, url, layout); finish(); } }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { finish(); } }).create().show(); mTracker.send(new HitBuilders.EventBuilder().setCategory("Activity : " + this.getClass().getSimpleName()) .setAction("Launched").build()); }
From source file:com.barryku.android.boxnet.AuthActivity.java
/** Called when the activity is first created. */ @Override/* w ww .j a v a 2s. c o 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:org.geometerplus.android.fbreader.network.auth.WebAuthorisationScreen.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); requestWindowFeature(Window.FEATURE_PROGRESS); SQLiteCookieDatabase.init(this); CookieSyncManager.createInstance(getApplicationContext()); CookieManager.getInstance().removeAllCookie(); final Intent intent = getIntent(); final Uri data = intent.getData(); if (data == null || data.getHost() == null) { finish();//ww w . ja va2s . co m return; } final String completeUrl = intent.getStringExtra(COMPLETE_URL_KEY); OrientationUtil.setOrientation(this, intent); final WebView view = new WebView(this); view.getSettings().setJavaScriptEnabled(true); view.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int progress) { setProgress(progress * 100); } }); view.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { setTitle(url); if (url != null && url.startsWith(completeUrl)) { final HashMap<String, String> cookies = new HashMap<String, String>(); final String cookieString = CookieManager.getInstance().getCookie(url); if (cookieString != null) { // cookieString is a string like NAME=VALUE [; NAME=VALUE] for (String pair : cookieString.split(";")) { final String[] parts = pair.split("=", 2); if (parts.length != 2) { continue; } cookies.put(parts[0].trim(), parts[1].trim()); } } storeCookies(data.getHost(), cookies); WebAuthorisationScreen.this.setResult(RESULT_OK); finish(); } } public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.ECLAIR_MR1) { // hack for auth problem in android 2.1 handler.proceed(); } else { super.onReceivedSslError(view, handler, error); } } }); setContentView(view); view.loadUrl(intent.getDataString()); }
From source file:com.barryku.android.boxnet.BrowseActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Uri uri = intent.getData(); Log.d(LOG_TAG, "loading folder from onNewIntent() from:" + uri); loadFolder(uri.getPath().substring(1)); //remove leading slash }
From source file:android.support.tests.GrantActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 12 && resultCode == RESULT_OK) { final ContentResolver resolver = getContentResolver(); resolver.takePersistableUriPermission(data.getData(), Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); }/*from w ww . j a v a2 s. c om*/ }
From source file:com.figo.campaignhelper.GenerateActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.generate);/*w w w.ja va 2 s . c om*/ mUrl = (TextView) findViewById(R.id.generated_url); mSend = (Button) findViewById(R.id.send); mImage = (ImageView) findViewById(R.id.image_view); Intent intent = getIntent(); if (null != intent) { mUri = intent.getData(); mReferrer = mUri.getQueryParameter("referrer"); mPackageName = mUri.getQueryParameter("id"); String url = intent.getDataString(); Log.i(GenerateActivity.class.getSimpleName(), url); // String.format("", args) mUrl.setText(url); // Bitmap bitmap; try { bitmap = encodeAsBitmap(url); mImage.setImageBitmap(bitmap); } catch (WriterException e) { e.printStackTrace(); } } mSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { doReferrer(); } }); }
From source file:edu.stanford.mobisocial.dungbeetle.HandleNfcContact.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); final Uri uri = intent.getData(); setContentView(R.layout.handle_give); Button saveButton = (Button) findViewById(R.id.save_contact_button); Button cancelButton = (Button) findViewById(R.id.cancel_button); Button mutualFriendsButton = (Button) findViewById(R.id.mutual_friends_button); mutualFriendsButton.setVisibility(View.GONE); if (uri != null && (uri.getScheme().equals(HomeActivity.SHARE_SCHEME) || uri.getSchemeSpecificPart().startsWith(FriendRequest.PREFIX_JOIN))) { mEmail = uri.getQueryParameter("email"); mName = uri.getQueryParameter("name"); if (mName == null) { mName = mEmail;// ww w.j av a 2s . c o m } TextView nameView = (TextView) findViewById(R.id.name_text); nameView.setText("Would you like to be friends with " + mName + "?"); final long cid = FriendRequest.acceptFriendRequest(HandleNfcContact.this, uri, false); saveButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { DBHelper helper = DBHelper.getGlobal(HandleNfcContact.this); IdentityProvider ident = new DBIdentityProvider(helper); try { JSONObject profile = new JSONObject(ident.userProfile()); byte[] data = FastBase64.decode(profile.getString("picture")); Helpers.updatePicture(HandleNfcContact.this, data); } catch (Exception e) { } // If asymmetric friend request, send public key. if (!NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) { FriendRequest.sendFriendRequest(HandleNfcContact.this, cid, uri.getQueryParameter("cap")); } Toast.makeText(HandleNfcContact.this, "Added " + mName + " as a friend.", Toast.LENGTH_SHORT) .show(); finish(); } }); cancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Helpers.deleteContact(HandleNfcContact.this, cid); finish(); } }); ImageView portraitView = (ImageView) findViewById(R.id.image); if (uri != null) { /* ((App)getApplication()).contactImages.lazyLoadImage( mEmail.hashCode(), Gravatar.gravatarUri(mEmail, 100), portraitView); */ //((App)getApplication()).contactImages.lazyLoadImage(mPicture.hashCode(), mPicture, portraitView); } } else { saveButton.setEnabled(false); cancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { finish(); } }); Toast.makeText(this, "Failed to receive contact.", Toast.LENGTH_SHORT).show(); Log.d(TAG, "Failed to handle " + uri); } }