List of usage examples for android.content Intent resolveActivity
public ComponentName resolveActivity(@NonNull PackageManager pm)
From source file:us.koller.todolist.Activities.InfoActivity.java
public void reportBugButtonClicked() { String emailContent = "<b>" + getString(R.string.do_not_remove) + " " + "</b>" + "Android Version: " + System.getProperty("os.version") + "; " + "SDK: " + Build.VERSION.SDK_INT + "<b>" + " " + getString(R.string.do_not_remove) + "</b>"; Intent shareIntent = ShareCompat.IntentBuilder.from(this).setType("text/plain") .addEmailTo("lukaskoller6@gmail.com") .setSubject("TODOList " + BuildConfig.VERSION_NAME + " Bug Report").setHtmlText(emailContent) .getIntent();/*from www . j a va 2 s. c o m*/ if (shareIntent.resolveActivity(getPackageManager()) != null) { startActivity(shareIntent); } }
From source file:com.luyaozhou.recognizethisforglass.ViewFinder.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_CAMERA: { // camera button (hardware) if (keyEnable) { camera.stopPreview(); // stop the preview camera.release(); // release the camera previewOn = false;//ww w . ja v a 2 s . c o m keyEnable = false; mHandler.post(new Runnable() { @Override public void run() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // capture image if (intent.resolveActivity(getPackageManager()) != null) { startActivityForResult(intent, PHOTO_REQUEST_CODE); } } }); } // Return false to allow the camera button to do its default action return false; } case KeyEvent.KEYCODE_DPAD_CENTER: // touchpad tap case KeyEvent.KEYCODE_ENTER: { if (keyEnable) { camera.stopPreview(); camera.release(); previewOn = false; // Don't release the camera in surfaceDestroyed() keyEnable = false; mHandler.post(new Runnable() { @Override public void run() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // capture image if (intent.resolveActivity(getPackageManager()) != null) { startActivityForResult(intent, PHOTO_REQUEST_CODE); } } }); } return false; } default: { return super.onKeyDown(keyCode, event); } } }
From source file:com.android.eventspace.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // The action bar home/up action should open or close the drawer. // ActionBarDrawerToggle will take care of this. if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }/*from ww w. ja v a 2 s. co m*/ // Handle action buttons switch (item.getItemId()) { case R.id.action_websearch: // create intent to perform web search for this planet Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, getActionBar().getTitle()); // catch event that there's no activity to handle intent if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show(); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.samsunghack.apps.android.noq.NavDrawerMainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // The action bar home/up action should open or close the drawer. // ActionBarDrawerToggle will take care of this. if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }// w w w .j a v a2 s .com // Handle action buttons switch (item.getItemId()) { case R.id.action_websearch: // create intent to perform web search for this planet Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, getActionBar().getTitle()); // catch event that there's no activity to handle intent if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show(); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.albedinsky.android.support.intent.BaseIntent.java
/** * Checks whether there is any activity that can handle the specified <var>intent</var>. * * @param intent The intent for which to resolve activity. * @return {@code True} if activity for the intent has been resolved/found so we can call * {@link #startActivity(Intent)} or {@link #startActivityForResult(Intent, int)} with that * intent, {@code false} otherwise, that means that there is no activity currently installed on * actual Android device that can handle that intent. *//*w w w.ja v a2 s.c om*/ @CheckResult @SuppressWarnings("ConstantConditions") protected boolean hasActivityForIntent(@NonNull Intent intent) { final Context context = mContextWrapper.getContext(); return intent.resolveActivity(context.getPackageManager()) != null; }
From source file:io.syng.activity.BaseActivity.java
@Override public void onDAppContinueSearch() { String url = CONTINUE_SEARCH_LINK; Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url));//from ww w. j ava 2 s. c om if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); closeDrawer(); mSearchTextView.getText().clear(); } }
From source file:com.example.android.implicitintents.MainActivity.java
/** * This method fires off an implicit Intent to open a webpage. * * @param url Url of webpage to open. Should start with http:// or https:// as that is the * scheme of the URI expected with this Intent according to the Common Intents page *///from w w w .j av a 2 s . c om private void openWebPage(String url) { /* * We wanted to demonstrate the Uri.parse method because its usage occurs frequently. You * could have just as easily passed in a Uri as the parameter of this method. */ Uri webpage = Uri.parse(url); /* * Here, we create the Intent with the action of ACTION_VIEW. This action allows the user * to view particular content. In this case, our webpage URL. */ Intent intent = new Intent(Intent.ACTION_VIEW, webpage); /* * This is a check we perform with every implicit Intent that we launch. In some cases, * the device where this code is running might not have an Activity to perform the action * with the data we've specified. Without this check, in those cases your app would crash. */ if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } }
From source file:me.trashout.fragment.CollectionPointDetailFragment.java
@OnClick(R.id.collection_point_detail_direction_btn) public void onDirectionClick() { if (mCollectionPoint != null && mCollectionPoint.getGps() != null) { Uri gmmIntentUri = Uri.parse("http://maps.google.com/maps?daddr=" + mCollectionPoint.getGps().getLat() + "," + mCollectionPoint.getGps().getLng()); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); if (mapIntent.resolveActivity(getActivity().getPackageManager()) != null) { startActivity(mapIntent);/*from w w w .ja v a2 s .com*/ } } }
From source file:net.survivalpad.android.ArticleEditActivity.java
@Override public void onTakePictureClicked(BaseEditorFragment fragment) { mEditorFragment = fragment;/*from w w w .j ava2s .c om*/ fileUri = MediaUtils.getOutputMediaFileUri(); Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); } }
From source file:com.rainmakerlabs.bleepsample.BleepService.java
private boolean testIntent(Intent launchIntent) { if (launchIntent == null || launchIntent.resolveActivity(getPackageManager()) == null) { Log.d(TAG, "testing intent: failed! " + launchIntent); return false; }/*from www. j a v a 2 s . c om*/ return true; }