List of usage examples for android.content Intent getDataString
public @Nullable String getDataString()
From source file:com.dycody.android.idealnote.ListFragment.java
/** * Notes list adapter initialization and association to view *///from ww w .j a v a 2 s . c om void initNotesList(Intent intent) { Log.d(Constants.TAG, "initNotesList intent: " + intent.getAction()); progress_wheel.setAlpha(1); list.setAlpha(0); // Search for a tag // A workaround to simplify it's to simulate normal search if (Intent.ACTION_VIEW.equals(intent.getAction()) && intent.getCategories() != null && intent.getCategories().contains(Intent.CATEGORY_BROWSABLE)) { searchTags = intent.getDataString().replace(UrlCompleter.HASHTAG_SCHEME, ""); goBackOnToggleSearchLabel = true; } // Searching searchQuery = searchQueryInstant; searchQueryInstant = null; if (searchTags != null || searchQuery != null || Intent.ACTION_SEARCH.equals(intent.getAction())) { // Using tags if (searchTags != null && intent.getStringExtra(SearchManager.QUERY) == null) { searchQuery = searchTags; NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getNotesByTag", searchQuery); } else { // Get the intent, verify the action and get the query if (intent.getStringExtra(SearchManager.QUERY) != null) { searchQuery = intent.getStringExtra(SearchManager.QUERY); searchTags = null; } NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getNotesByPattern", searchQuery); } toggleSearchLabel(true); } else { // Check if is launched from a widget with categories if ((Constants.ACTION_WIDGET_SHOW_LIST.equals(intent.getAction()) && intent.hasExtra(Constants.INTENT_WIDGET)) || !TextUtils.isEmpty(mainActivity.navigationTmp)) { String widgetId = intent.hasExtra(Constants.INTENT_WIDGET) ? intent.getExtras().get(Constants.INTENT_WIDGET).toString() : null; if (widgetId != null) { String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, ""); String categoryId = TextHelper.checkIntentCategory(sqlCondition); mainActivity.navigationTmp = !TextUtils.isEmpty(categoryId) ? categoryId : null; } intent.removeExtra(Constants.INTENT_WIDGET); if (mainActivity.navigationTmp != null) { Long categoryId = Long.parseLong(mainActivity.navigationTmp); NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getNotesByCategory", categoryId); } else { NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getAllNotes", true); } } else { NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getAllNotes", true); } } }
From source file:org.safegees.safegees.gui.view.PrincipalMapActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_IMAGE_CODE && resultCode == Activity.RESULT_OK) { //Set selected image as bitmap bitmap = ImageController.buildBitmapFromData(this, data.getData()); //Send User Image this.sendUserImage(); } else if (requestCode == REQUEST_CONTACTS_CODE && resultCode == Activity.RESULT_OK) { if (getSupportFragmentManager().getBackStackEntryCount() > 0) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out); transaction.remove(getActiveFragment()); getSupportFragmentManager().popBackStack(); transaction.commitAllowingStateLoss(); this.floatingAddContactButton.hide(); }/*from www .j ava 2 s . com*/ mapFragment.onResume(); this.connectivityOn(); } else if (requestCode == REQUEST_CONTACTS_CODE && resultCode == Activity.RESULT_CANCELED) { //Refresh the contacts fragment adapter list view if (this.contactsFragment != null) { this.contactsFragment.refresh(); } //this.onBackPressed(); } if (data != null) { //data != null when image data is received Log.e("DATA", data.getDataString()); ProfileUserFragment myFragment = (ProfileUserFragment) getSupportFragmentManager() .findFragmentByTag("profile"); if (myFragment != null && myFragment.isVisible()) { Log.i("ProfileFragment", "Add poto"); myFragment.setImageBitmap(bitmap); //Store in /images ImageController.storeUserImage(this); //Reload the header image loadNavMenuProfile(); } } //super.onActivityResult(requestCode, resultCode, data); }
From source file:net.fred.feedex.activity.EditFeedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_feed_edit); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*ww w .j av a 2s . c o m*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); setResult(RESULT_CANCELED); Intent intent = getIntent(); mTabHost = (TabHost) findViewById(R.id.tabHost); mNameEditText = (EditText) findViewById(R.id.feed_title); mUrlEditText = (EditText) findViewById(R.id.feed_url); mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext); mFiltersListView = (ListView) findViewById(android.R.id.list); View tabWidget = findViewById(android.R.id.tabs); mTabHost.setup(); mTabHost.addTab(mTabHost.newTabSpec("feedTab").setIndicator(getString(R.string.tab_feed_title)) .setContent(R.id.feed_tab)); mTabHost.addTab(mTabHost.newTabSpec("filtersTab").setIndicator(getString(R.string.tab_filters_title)) .setContent(R.id.filters_tab)); mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String s) { invalidateOptionsMenu(); } }); if (savedInstanceState != null) { mTabHost.setCurrentTab(savedInstanceState.getInt(STATE_CURRENT_TAB)); } if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) { setTitle(R.string.new_feed_title); tabWidget.setVisibility(View.GONE); if (intent.hasExtra(Intent.EXTRA_TEXT)) { mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); } } else if (intent.getAction().equals(Intent.ACTION_VIEW)) { setTitle(R.string.new_feed_title); tabWidget.setVisibility(View.GONE); mUrlEditText.setText(intent.getDataString()); } else if (intent.getAction().equals(Intent.ACTION_EDIT)) { setTitle(R.string.edit_feed_title); mFiltersCursorAdapter = new FiltersCursorAdapter(this, Constants.EMPTY_CURSOR); mFiltersListView.setAdapter(mFiltersCursorAdapter); mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { startSupportActionMode(mFilterActionModeCallback); mFiltersCursorAdapter.setSelectedFilter(position); mFiltersListView.invalidateViews(); return true; } }); getLoaderManager().initLoader(0, null, this); if (savedInstanceState == null) { Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null); if (cursor != null && cursor.moveToNext()) { mNameEditText.setText(cursor.getString(0)); mUrlEditText.setText(cursor.getString(1)); mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1); if (cursor.getInt(3) == 1) { // if it's a group, we cannot edit it finish(); } } else { UiUtils.showMessage(EditFeedActivity.this, R.string.error); finish(); } if (cursor != null) { cursor.close(); } } } }
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();/*from w ww . j a v a 2s. 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.dish.browser.activity.BrowserActivity.java
public void handleNewIntent(Intent intent) { String url = null;//from w w w .j ava 2s . c om if (intent != null) { url = intent.getDataString(); } int num = 0; if (intent != null && intent.getExtras() != null) { num = intent.getExtras().getInt(getPackageName() + ".Origin"); } if (num == 1) { mCurrentView.loadUrl(url); } else if (url != null) { if (url.startsWith(Constants.FILE)) { Utils.showToast(this, getResources().getString(R.string.message_blocked_local)); url = null; } newTab(url, true); mIsNewIntent = true; } }
From source file:net.bluecarrot.lite.MainActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { //used to upload files // code for all versions except of Lollipop if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { if (requestCode == FILECHOOSER_RESULTCODE) { if (null == this.mUploadMessage) return; Uri result = null;// ww w .ja va 2s.c o m try { if (resultCode != RESULT_OK) result = null; else { // retrieve from the private variable if the intent is null result = data == null ? mCapturedImageURI : data.getData(); } } catch (Exception e) { Toast.makeText(getApplicationContext(), "activity :" + e, Toast.LENGTH_LONG).show(); } mUploadMessage.onReceiveValue(result); mUploadMessage = null; } } // end of code for all versions except of Lollipop // start of code for Lollipop only if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (requestCode != FILECHOOSER_RESULTCODE || mFilePathCallback == null) { super.onActivityResult(requestCode, resultCode, data); return; } Uri[] results = null; // check that the response is a good one if (resultCode == Activity.RESULT_OK) { if (data == null || data.getData() == null) { // if there is not data, then we may have taken a photo if (mCameraPhotoPath != null) { results = new Uri[] { Uri.parse(mCameraPhotoPath) }; } } else { String dataString = data.getDataString(); if (dataString != null) { results = new Uri[] { Uri.parse(dataString) }; } } } mFilePathCallback.onReceiveValue(results); mFilePathCallback = null; } // end of code for Lollipop only }
From source file:org.mozilla.gecko.GeckoApp.java
private String getURIFromIntent(Intent intent) { String uri = intent.getDataString(); if (uri != null) return uri; final String action = intent.getAction(); if (ACTION_WEBAPP.equals(action) || ACTION_BOOKMARK.equals(action)) { uri = intent.getStringExtra("args"); if (uri != null && uri.startsWith("--url=")) { uri.replace("--url=", ""); }/*from w w w .j av a 2 s . co m*/ } return uri; }
From source file:com.bt.download.android.gui.activities.MainActivity.java
@Override protected void onNewIntent(Intent intent) { if (isShutdown(intent)) { return;/*from ww w . ja v a2 s .c om*/ } String action = intent.getAction(); //onResumeFragments(); if (action != null && action.equals(Constants.ACTION_SHOW_TRANSFERS)) { if (Ads.isLoaded(Fetcher.AdFormat.interstitial, Constants.TAG_INTERSTITIAL_WIDGET)) { Ads.showAppWidget(this, null, Constants.TAG_INTERSTITIAL_WIDGET, Ads.ShowMode.FULL_SCREEN); } controller.showTransfers(TransferStatus.ALL); } else if (action != null && action.equals(Constants.ACTION_OPEN_TORRENT_URL)) { //Open a Torrent from a URL or from a local file :), say from Astro File Manager. /** * TODO: Ask @aldenml the best way to plug in NewTransferDialog. * I've refactored this dialog so that it is forced (no matter if the setting * to not show it again has been used) and when that happens the checkbox is hidden. * * However that dialog requires some data about the download, data which is not * obtained until we have instantiated the Torrent object. * * I'm thinking that we can either: * a) Pass a parameter to the transfer manager, but this would probably * not be cool since the transfer manager (I think) should work independently from * the UI thread. * * b) Pass a "listener" to the transfer manager, once the transfer manager has the torrent * it can notify us and wait for the user to decide wether or not to continue with the transfer * * c) Forget about showing that dialog, and just start the download, the user can cancel it. */ //Show me the transfer tab Intent i = new Intent(this, MainActivity.class); i.setAction(Constants.ACTION_SHOW_TRANSFERS); i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(i); //go! TransferManager.instance().downloadTorrent(intent.getDataString()); } // When another application wants to "Share" a file and has chosen FrostWire to do so. // We make the file "Shared" so it's visible for other FrostWire devices on the local network. else if (action != null && (action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_SEND_MULTIPLE))) { controller.handleSendAction(intent); } if (intent.hasExtra(Constants.EXTRA_DOWNLOAD_COMPLETE_NOTIFICATION)) { controller.showTransfers(TransferStatus.COMPLETED); TransferManager.instance().clearDownloadsToReview(); try { ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)) .cancel(Constants.NOTIFICATION_DOWNLOAD_TRANSFER_FINISHED); Bundle extras = intent.getExtras(); if (extras.containsKey(Constants.EXTRA_DOWNLOAD_COMPLETE_PATH)) { File file = new File(extras.getString(Constants.EXTRA_DOWNLOAD_COMPLETE_PATH)); if (file.isFile()) { UIUtils.openFile(this, file.getAbsoluteFile()); } } } catch (Throwable e) { LOG.warn("Error handling download complete notification", e); } } }
From source file:com.bookkos.bircle.CaptureActivity.java
@Override protected void onResume() { super.onResume(); // cameraManager?????????????(onCreate????????????) cameraManager = new CameraManager(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); // resultView = findViewById(R.id.result_view); handler = null;// w w w .j a v a 2 s. c om lastResult = null; registFlag = 0; resetStatusView(); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { initCamera(surfaceHolder); } else { surfaceHolder.addCallback(this); } bircleBeepManager.updatePrefs(); ambientLightManager.start(cameraManager); inactivityTimer.onResume(); Intent intent = getIntent(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true) && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)); source = IntentSource.NONE; decodeFormats = null; characterSet = null; if (intent != null) { String action = intent.getAction(); String dataString = intent.getDataString(); if (Intents.Scan.ACTION.equals(action)) { source = IntentSource.NATIVE_APP_INTENT; decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); decodeHints = DecodeHintManager.parseDecodeHints(intent); if (intent.hasExtra(Intents.Scan.WIDTH) && intent.hasExtra(Intents.Scan.HEIGHT)) { int width = intent.getIntExtra(Intents.Scan.WIDTH, 0); int height = intent.getIntExtra(Intents.Scan.HEIGHT, 0); if (width > 0 && height > 0) { cameraManager.setManualFramingRect(width, height); } } String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE); if (customPromptMessage != null) { } } else if (dataString != null && dataString.contains("http://www.google") && dataString.contains("/m/products/scan")) { source = IntentSource.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (isZXingURL(dataString)) { source = IntentSource.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(dataString); decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); decodeHints = DecodeHintManager.parseDecodeHints(inputUri); } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } }