List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:com.upwork.example_upworkapi.MyActivity.java
/** * Callback once we are done with the authorization of this app * @param intent/*ww w. j av a 2 s.c o m*/ */ @Override public void onNewIntent(Intent intent) { super.onNewIntent(intent); // Verify OAuth callback Uri uri = intent.getData(); if (uri != null && uri.getScheme().equals(OAUTH_CALLBACK_SCHEME)) { String verifier = uri.getQueryParameter(OAuth.OAUTH_VERIFIER); new UpworkRetrieveAccessTokenTask().execute(verifier); } }
From source file:com.appdynamics.demo.gasp.service.RESTIntentService.java
@Override protected void onHandleIntent(Intent intent) { Uri action = intent.getData(); Bundle extras = intent.getExtras();/*from w w w .j a va 2 s .co m*/ if (extras == null || action == null || !extras.containsKey(EXTRA_RESULT_RECEIVER)) { Log.e(TAG, "You did not pass extras or data with the Intent."); return; } int verb = extras.getInt(EXTRA_HTTP_VERB, GET); Bundle params = extras.getParcelable(EXTRA_PARAMS); Bundle headers = extras.getParcelable(EXTRA_HEADERS); ResultReceiver receiver = extras.getParcelable(EXTRA_RESULT_RECEIVER); try { HttpRequestBase request = null; // Get query params from Bundle and build URL switch (verb) { case GET: { request = new HttpGet(); attachUriWithQuery(request, action, params); } break; case DELETE: { request = new HttpDelete(); attachUriWithQuery(request, action, params); } break; case POST: { request = new HttpPost(); request.setURI(new URI(action.toString())); HttpPost postRequest = (HttpPost) request; if (params != null) { UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params)); postRequest.setEntity(formEntity); } } break; case PUT: { request = new HttpPut(); request.setURI(new URI(action.toString())); HttpPut putRequest = (HttpPut) request; if (params != null) { UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params)); putRequest.setEntity(formEntity); } } break; } // Get Headers from Bundle for (BasicNameValuePair header : paramsToList(headers)) { request.setHeader(header.getName(), header.getValue()); } if (request != null) { HttpClient client = new DefaultHttpClient(); Log.d(TAG, "Executing request: " + verbToString(verb) + ": " + action.toString()); HttpResponse response = client.execute(request); HttpEntity responseEntity = response.getEntity(); StatusLine responseStatus = response.getStatusLine(); int statusCode = responseStatus != null ? responseStatus.getStatusCode() : 0; if ((responseEntity != null) && (responseStatus.getStatusCode() == 200)) { Bundle resultData = new Bundle(); resultData.putString(REST_RESULT, EntityUtils.toString(responseEntity)); receiver.send(statusCode, resultData); } else { receiver.send(statusCode, null); } } } catch (URISyntaxException e) { Log.e(TAG, "URI syntax was incorrect. " + verbToString(verb) + ": " + action.toString(), e); receiver.send(0, null); } catch (UnsupportedEncodingException e) { Log.e(TAG, "A UrlEncodedFormEntity was created with an unsupported encoding.", e); receiver.send(0, null); } catch (ClientProtocolException e) { Log.e(TAG, "There was a problem when sending the request.", e); receiver.send(0, null); } catch (IOException e) { Log.e(TAG, "There was a problem when sending the request.", e); receiver.send(0, null); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.amytech.android.library.views.imagechooser.api.MediaChooserManager.java
@SuppressLint("NewApi") private void processImageFromGallery(Intent data) { if (data != null && data.getDataString() != null) { String uri = data.getData().toString(); sanitizeURI(uri);//from ww w . j a v a2 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; MediaProcessorThread thread = null; if (!wasVideoSelected(data)) { thread = new ImageProcessorThread(path, foldername, shouldCreateThumbnails); ((ImageProcessorThread) thread).setListener(this); } else { thread = new VideoProcessorThread(path, foldername, shouldCreateThumbnails); ((VideoProcessorThread) thread).setListener(this); } thread.setContext(getContext()); thread.start(); } } else { onError("Image Uri was null!"); } }
From source file:cc.metapro.openct.allclasses.ExcelDialog.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == FILE_SELECT_CODE && resultCode == AppCompatActivity.RESULT_OK) { Uri uri = data.getData(); String path = null;/*from w w w . ja v a 2s. c o m*/ path = FileUtils.getPath(getActivity(), uri); if (path != null) { File file = new File(path); Log.d("FileChooser", file.getAbsolutePath()); try { String table = ExcelHelper.xlsxToTable(path); mCallback.onJsonResult(ExcelHelper.tableToJson(table)); dismiss(); } catch (JSONException e) { e.printStackTrace(); } } } }
From source file:com.amytech.android.library.views.imagechooser.api.VideoChooserManager.java
@SuppressLint("NewApi") private void processVideoFromGallery(Intent data) { if (data != null && data.getDataString() != null) { String uri = data.getData().toString(); sanitizeURI(uri);//from w w w .j a v a 2 s . 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; VideoProcessorThread thread = new VideoProcessorThread(path, foldername, shouldCreateThumbnails); thread.setListener(this); thread.setContext(getContext()); thread.start(); } } }
From source file:com.example.cuisoap.agrimac.machineRegister.machineInfoFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { Uri uri = data.getData(); Log.e("uri", uri.toString()); ContentResolver cr = context.getContentResolver(); try {//from w w w.java 2s .c o m Bitmap bitmap = BitmapFactory.decodeStream(cr.openInputStream(uri)); bitmap = ImageUtils.comp(bitmap); switch (requestCode) { case 1: license_pic1.setImageBitmap(bitmap); license_path1 = ImageUtils.saveMyBitmap(bitmap, "machineinfo"); license_pic1.setVisibility(View.VISIBLE); license1.setVisibility(View.GONE); license_pic1.setOnClickListener(myOnClickListener); break; case 2: license_pic2.setImageBitmap(bitmap); license_path2 = ImageUtils.saveMyBitmap(bitmap, "machineinfo"); license_pic2.setVisibility(View.VISIBLE); license2.setVisibility(View.GONE); license_pic2.setOnClickListener(myOnClickListener); break; } } catch (FileNotFoundException e) { Log.e("Exception", e.getMessage(), e); } } else { Toast.makeText(context, "?", Toast.LENGTH_SHORT).show(); } super.onActivityResult(requestCode, resultCode, data); }
From source file:bander.notepad.NoteListAppCompat.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Notepad.setAppCompatThemeFromPreferences(this, "NoteList"); SharedPreferences mSettings = PreferenceManager.getDefaultSharedPreferences(this); setContentView(R.layout.list_appcompat); ViewStub stub = (ViewStub) findViewById(R.id.toolbarWrapper); if (mSettings.getBoolean("darkAppCompatTheme", false)) stub.setLayoutResource(R.layout.toolbar_dark); else//from w w w .j a v a2s . c om stub.setLayoutResource(R.layout.toolbar_light); stub.inflate(); toolbar = (Toolbar) findViewById(R.id.toolbar); Notepad.setToolbarColor(this); setSupportActionBar(toolbar); Intent intent = getIntent(); if (intent.getData() == null) { intent.setData(Note.CONTENT_URI); } registerForContextMenu(getListView()); }
From source file:com.weiboa.activity.SignInActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Uri uri = intent.getData(); if (uri != null) { if (OAuthConntect.CALLBACK_URL.getScheme().equals(uri.getScheme())) { getIntent().setData(null);//from w ww. j a v a2 s . c o m boolean isAuthenticated = mOAuthConntect.getAccessToken(uri, mDb); if (isAuthenticated) { new VerifyCredentialTask().execute(); } } } super.onNewIntent(intent); }
From source file:at.tomtasche.reader.ui.activity.MainActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); if (intent.getData() != null) { loadUri(intent.getData());/*ww w .j a v a 2s.com*/ } }
From source file:ca.rmen.android.poetassistant.main.PagerAdapter.java
PagerAdapter(Context context, FragmentManager fm, Intent intent) { super(fm);/*from ww w . java 2 s. co m*/ Log.v(TAG, "Constructor: intent = " + intent); mContext = context; Uri initialQuery = intent.getData(); // Deep link to query in a specific tab if (initialQuery != null) { Tab tab = Tab.parse(initialQuery.getHost()); if (tab == Tab.PATTERN) { mInitialPatternQuery = initialQuery.getLastPathSegment(); } else if (tab == Tab.RHYMER) { mInitialRhymeQuery = initialQuery.getLastPathSegment(); } else if (tab == Tab.THESAURUS) { mInitialThesaurusQuery = initialQuery.getLastPathSegment(); } else if (tab == Tab.DICTIONARY) { mInitialDictionaryQuery = initialQuery.getLastPathSegment(); } else if (Constants.DEEP_LINK_QUERY.equals(initialQuery.getHost())) { mInitialRhymeQuery = initialQuery.getLastPathSegment(); mInitialThesaurusQuery = initialQuery.getLastPathSegment(); mInitialDictionaryQuery = initialQuery.getLastPathSegment(); } } // Text shared from another app: else if (Intent.ACTION_SEND.equals(intent.getAction())) { mInitialPoemText = intent.getStringExtra(Intent.EXTRA_TEXT); } }