List of usage examples for android.content Intent getDataString
public @Nullable String getDataString()
From source file:com.kbeanie.imagechooser.api.ImageChooserManager.java
@SuppressLint("NewApi") private void processImageFromGallery(Intent data) { if (data != null && data.getDataString() != null) { String uri = data.getData().toString(); sanitizeURI(uri);// www . j av a 2 s. co m if (filePathOriginal == null || TextUtils.isEmpty(filePathOriginal)) { onError("File path was null"); } else { if (BuildConfig.DEBUG) { Log.i(TAG, "File: " + filePathOriginal); } String path = filePathOriginal; ImageProcessorThread thread = new ImageProcessorThread(path, foldername, shouldCreateThumbnails); thread.clearOldFiles(clearOldFiles); thread.setListener(this); thread.setContext(getContext()); thread.start(); } } else { onError("Image Uri was null!"); } }
From source file:com.nbossard.packlist.gui.MainActivity.java
/** * For deep-app indexing./*from w ww.ja va 2s .co m*/ * @param intent sic */ @DebugLog protected final void onNewIntent(final Intent intent) { String action = intent.getAction(); String data = intent.getDataString(); if (Intent.ACTION_VIEW.equals(action) && data != null) { String tripId = data.substring(data.lastIndexOf("/") + 1); Trip loadedTrip = mSavingModule.loadSavedTrip(UUID.fromString(tripId)); openTripDetailFragment(loadedTrip); } }
From source file:com.olheingenieros.listexample.sync.TutListDownloaderService.java
@Override public int onStartCommand(final Intent intent, final int flags, final int startID) { URL tutorialPath;//w ww . j a v a2 s .c om try { tutorialPath = new URL(intent.getDataString()); tutorialDownloader = new DownloaderTask(); tutorialDownloader.execute(tutorialPath); } catch (final MalformedURLException e) { LOGE(TAG, "BAD URL", e); } return Service.START_FLAG_REDELIVERY; }
From source file:org.quantumbadger.redreader.activities.AlbumListingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PrefsUtility.applyTheme(this); OptionsMenuUtility.fixActionBar(AlbumListingActivity.this, getString(R.string.imgur_album)); if (getActionBar() != null) { getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); }/*from www .j a v a 2 s . co m*/ final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences) && PrefsUtility.appearance_theme(this, sharedPreferences) == PrefsUtility.AppearanceTheme.NIGHT; if (solidblack) getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK)); final Intent intent = getIntent(); mUrl = intent.getDataString(); if (mUrl == null) { finish(); return; } final Matcher matchImgur = LinkHandler.imgurAlbumPattern.matcher(mUrl); final String albumId; if (matchImgur.find()) { albumId = matchImgur.group(2); } else { Log.e("AlbumListingActivity", "URL match failed"); revertToWeb(); return; } Log.i("AlbumListingActivity", "Loading URL " + mUrl + ", album id " + albumId); final ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal); progressBar.setIndeterminate(true); final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(progressBar); ImgurAPI.getAlbumInfo(this, albumId, Constants.Priority.IMAGE_VIEW, 0, new GetAlbumInfoListener() { @Override public void onFailure(final RequestFailureType type, final Throwable t, final StatusLine status, final String readableMessage) { Log.e("AlbumListingActivity", "getAlbumInfo call failed: " + type); if (status != null) Log.e("AlbumListingActivity", "status was: " + status.toString()); if (t != null) Log.e("AlbumListingActivity", "exception was: ", t); // It might be a single image, not an album if (status == null) { revertToWeb(); return; } ImgurAPI.getImageInfo(AlbumListingActivity.this, albumId, Constants.Priority.IMAGE_VIEW, 0, new GetImageInfoListener() { @Override public void onFailure(final RequestFailureType type, final Throwable t, final StatusLine status, final String readableMessage) { Log.e("AlbumListingActivity", "Image info request also failed: " + type); revertToWeb(); } @Override public void onSuccess(final ImageInfo info) { Log.i("AlbumListingActivity", "Link was actually an image."); LinkHandler.onLinkClicked(AlbumListingActivity.this, info.urlOriginal); finish(); } @Override public void onNotAnImage() { Log.i("AlbumListingActivity", "Not an image either"); revertToWeb(); } }); } @Override public void onSuccess(final ImgurAPI.AlbumInfo info) { Log.i("AlbumListingActivity", "Got album, " + info.images.size() + " image(s)"); AndroidApi.UI_THREAD_HANDLER.post(new Runnable() { @Override public void run() { if (info.title != null && !info.title.trim().isEmpty()) { OptionsMenuUtility.fixActionBar(AlbumListingActivity.this, getString(R.string.imgur_album) + ": " + info.title); } layout.removeAllViews(); final ListView listView = new ListView(AlbumListingActivity.this); listView.setAdapter(new AlbumAdapter(info)); layout.addView(listView); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { LinkHandler.onLinkClicked(AlbumListingActivity.this, info.images.get(position).urlOriginal, false, null, info, position); } }); } }); } }); setContentView(layout); }
From source file:org.voidsink.anewjkuapp.activity.SettingsActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); if (intent != null && ACTION_PREFS_LEGACY.equals(intent.getAction())) { Fragment fragment = null;//from w ww .j a va2 s. com try { String clazzname = intent.getDataString(); if (clazzname != null) { Class<?> clazz = getClassLoader().loadClass(clazzname); if (PreferenceFragment.class.isAssignableFrom(clazz)) { fragment = (Fragment) clazz.newInstance(); } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { e.printStackTrace(); } if (fragment != null) { Fragment oldFragment = getSupportFragmentManager().findFragmentByTag(ARG_SHOW_FRAGMENT); if (oldFragment == null || !fragment.getClass().equals(oldFragment.getClass())) { getSupportFragmentManager().beginTransaction() .replace(R.id.content_container, fragment, ARG_SHOW_FRAGMENT) .addToBackStack(fragment.getClass().getCanonicalName()).commit(); } } } }
From source file:com.figo.campaignhelper.GenerateActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.generate);//from w w w. j a v a2 s . c o m 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:com.Jsu.framework.image.imageChooser.ImageChooserManager.java
@SuppressLint("NewApi") private void processImageFromGallery(Intent data) { if (data != null && data.getDataString() != null) { String uri = data.getData().toString(); sanitizeURI(uri);/* ww w. j av a 2s . c o m*/ if (filePathOriginal == null || TextUtils.isEmpty(filePathOriginal)) { onError("File path was null"); } else { if (BuildConfig.DEBUG) { Log.i(TAG, "File: " + filePathOriginal); } String path = filePathOriginal; ImageProcessorThread thread = new ImageProcessorThread(path, foldername, shouldCreateThumbnails); thread.clearOldFiles(clearOldFiles); thread.setListener(this); thread.setContext(getContext()); thread.start(); } } else if (data.getClipData() != null || data.hasExtra("uris")) { // Multiple Images String[] filePaths; if (data.hasExtra("uris")) { ArrayList<Uri> uris = data.getParcelableArrayListExtra("uris"); filePaths = new String[uris.size()]; for (int i = 0; i < uris.size(); i++) { filePaths[i] = uris.get(i).toString(); } } else { ClipData clipData = data.getClipData(); int count = clipData.getItemCount(); filePaths = new String[count]; for (int i = 0; i < count; i++) { ClipData.Item item = clipData.getItemAt(i); Log.i(TAG, "processImageFromGallery: Item: " + item.getUri()); filePaths[i] = item.getUri().toString(); } } ImageProcessorThread thread = new ImageProcessorThread(filePaths, foldername, shouldCreateThumbnails); thread.clearOldFiles(clearOldFiles); thread.setListener(this); thread.setContext(getContext()); thread.start(); // } else if () { } else { onError("Image Uri was null!"); } }
From source file:com.microsoft.azure.engagement.cordova.AZME.java
public void onNewIntent(Intent intent) { super.onNewIntent(intent); String invokeString = intent.getDataString(); if (invokeString != null && !invokeString.equals("")) { EngagementShared.instance().logD("onNewIntent, handleOpenURL " + invokeString); if (onOpenUrlHandlerContext != null) { PluginResult result = new PluginResult(PluginResult.Status.OK, invokeString); result.setKeepCallback(true); onOpenUrlHandlerContext.sendPluginResult(result); } else//from w w w . j a v a 2 s .c o m EngagementShared.instance().logD("Cannot trigger onOpenUrl if enableURL not previously called"); } }
From source file:org.akvo.flow.activity.RecordListActivity.java
@Override protected void onNewIntent(Intent intent) { setIntent(intent);/*from www. jav a 2 s. c o m*/ if (Intent.ACTION_VIEW.equals(intent.getAction())) { String surveyedLocaleId = intent.getDataString(); onRecordSelected(surveyedLocaleId); } }
From source file:com.audiokernel.euphonyrmt.URIHandlerActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_urihandler); final Intent intent = getIntent(); final FragmentManager fragmentManager = getSupportFragmentManager(); final StreamsFragment streamsFragment = (StreamsFragment) fragmentManager .findFragmentById(R.id.streamsFragment); if (!Intent.ACTION_VIEW.equals(intent.getAction())) { finish();//from w w w . ja v a 2 s .c o m } streamsFragment.addEdit(-1, intent.getDataString()); }