Esempio n. 1
0
  /**
   * Prepares the help menu item by doing the following. - If the helpUrlString is empty or null,
   * the help menu item is made invisible. - Otherwise, this makes the help menu item visible and
   * sets the intent for the help menu item to view the URL.
   *
   * @return returns whether the help menu item has been made visible.
   */
  public static boolean prepareHelpMenuItem(
      Context context, MenuItem helpMenuItem, String helpUrlString) {
    if (TextUtils.isEmpty(helpUrlString)) {
      // The help url string is empty or null, so set the help menu item to be invisible.
      helpMenuItem.setVisible(false);

      // return that the help menu item is not visible (i.e. false)
      return false;
    } else {
      // The help url string exists, so first add in some extra query parameters.
      final Uri fullUri = uriWithAddedParameters(context, Uri.parse(helpUrlString));

      // Then, create an intent that will be fired when the user
      // selects this help menu item.
      Intent intent = new Intent(Intent.ACTION_VIEW, fullUri);
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

      // Set the intent to the help menu item, show the help menu item in the overflow
      // menu, and make it visible.
      ComponentName component = intent.resolveActivity(context.getPackageManager());
      if (component != null) {
        helpMenuItem.setIntent(intent);
        helpMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        helpMenuItem.setVisible(true);
      } else {
        helpMenuItem.setVisible(false);
        return false;
      }

      // return that the help menu item is visible (i.e., true)
      return true;
    }
  }
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference == mReboot) {
      PowerManager pm = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE);
      pm.reboot("Resetting density");
      return true;

    } else if (preference == mClearMarketData) {

      new ClearMarketDataTask().execute("");
      return true;

    } else if (preference == mOpenMarket) {
      Intent openMarket =
          new Intent(Intent.ACTION_MAIN)
              .addCategory(Intent.CATEGORY_APP_MARKET)
              .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      ComponentName activityName = openMarket.resolveActivity(getActivity().getPackageManager());
      if (activityName != null) {
        mContext.startActivity(openMarket);
      } else {
        preference.setSummary(
            "Coulnd't open the market! If you're sure it's installed, open it yourself from the launcher.");
      }
      return true;
    }

    return super.onPreferenceTreeClick(preferenceScreen, preference);
  }
Esempio n. 3
0
  public static void SetFileExplorerLink(
      TextView txtFilename, Spanned htmlString, final String pathToLinkTo, final Context context) {

    final Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.parse("file://" + pathToLinkTo), "resource/folder");
    intent.setAction(Intent.ACTION_VIEW);

    if (intent.resolveActivity(context.getPackageManager()) != null) {
      txtFilename.setLinksClickable(true);
      txtFilename.setClickable(true);
      txtFilename.setMovementMethod(LinkMovementMethod.getInstance());
      txtFilename.setSelectAllOnFocus(false);
      txtFilename.setTextIsSelectable(false);
      txtFilename.setText(htmlString);

      txtFilename.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              context.startActivity(intent);
            }
          });
    }
  }
  private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // Ensure that there's a camera activity to handle the intent
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
      photoFile = null;
      try {
        photoFile = createImageFile();
      } catch (IOException ex) {
        Log.e(LOG, "F**k!", ex);
        Util.showErrorToast(ctx, getString(R.string.file_error));
        return;
      }
      if (photoFile != null) {
        Log.w(LOG, "dispatchTakePictureIntent - start pic intent");

        if (mLocationClient.isConnected()) {
          Log.w(LOG, "## requesting mLocationClient updates before picture taken");
          mLocationClient.requestLocationUpdates(mLocationRequest, this);
        } else {
          mLocationClient.connect();
        }
        takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
        startActivityForResult(takePictureIntent, CAPTURE_IMAGE);
      }
    }
  }
Esempio n. 5
0
  private void attachFromCamera() {

    AnalyticsManager.getInstance()
        .sendEvent(
            AnalyticsManager.CATEGORY_MESSAGES, AnalyticsManager.ACTION_ATTACH_FROM_CAMERA, mLabel);

    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (cameraIntent.resolveActivity(mContext.getPackageManager()) != null) {

      File file = null;
      try {
        file = createImageFile();
      } catch (IOException e) {
        e.printStackTrace();
      }

      if (file != null) {
        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
        mActivityLauncher.startActivityForResult(cameraIntent, REQUEST_CODE_CAMERA);
      }
    } else {
      // Send a toast saying there was a camera error
      if (mContext != null) {
        String message = mContext.getResources().getString(R.string.attachment_camera_error);
        Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
      }
    }
  }
  private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // Ensure that there's a camera activity to handle the intent
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
      // Create the File where the photo should go
      System.out.println("\nCriando arquivo\n");
      File photoFile = null;
      try {
        photoFile = createImageFile();
        System.out.println("\nArquivo criado com sucesso!\n");
      } catch (IOException ex) {
        // Error occurred while creating the File
        System.out.println("\n\nErro ao tentar gravar a foto em " + mCurrentPhotoPath);
        System.out.println("\n");
        ex.printStackTrace();
      }
      // Continue only if the File was successfully created
      if (photoFile != null) {
        System.out.println("\nRecuperando o extra_output!\n");

        takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
        System.out.println("\nIniciando startActivityForResult\n");
        // startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
        startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
      }
    }
  }
  // NOTE: Currently not reentrant / doesn't support concurrent requests
  @ReactMethod
  public void launchCamera(ReadableMap options, Callback callback) {
    if (options.hasKey("noData")) {
      noData = options.getBoolean("noData");
    }

    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (cameraIntent.resolveActivity(mMainActivity.getPackageManager()) == null) {
      callback.invoke(true, "error resolving activity");
      return;
    }

    // we create a tmp file to save the result
    File imageFile;
    try {
      imageFile =
          File.createTempFile(
              "exponent_capture_",
              ".jpg",
              Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES));
    } catch (IOException e) {
      e.printStackTrace();
      return;
    }
    if (imageFile == null) {
      callback.invoke(true, "error file not created");
      return;
    }
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));
    mCameraCaptureURI = Uri.fromFile(imageFile);
    mCallback = callback;
    mMainActivity.startActivityForResult(cameraIntent, REQUEST_LAUNCH_CAMERA);
  }
Esempio n. 8
0
 public void buscarFoto(View v) {
   Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
   intent.setType("image/*");
   if (intent.resolveActivity(getPackageManager()) != null) {
     startActivityForResult(intent, REQUEST_IMAGE_GET);
   }
 }
Esempio n. 9
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.camera:
        if (checkWritePermissions()) startCamera();
        return true;

      case R.id.gallery:
        Intent intent = new Intent();
        intent.setType("image/*");
        // Allow multiple selection for API 18+
        if (isApiLevel(Build.VERSION_CODES.JELLY_BEAN_MR2))
          intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
        intent.setAction(Intent.ACTION_GET_CONTENT);

        if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
          startActivityForResult(intent, RequestCodes.SELECT_PHOTO);
        } else {
          // TODO?
        }
        return true;

      case R.id.link:
        getChildFragmentManager()
            .beginTransaction()
            .add(UploadLinkDialogFragment.newInstance(null), UploadLinkDialogFragment.TAG)
            .commit();
        return true;
    }

    return super.onOptionsItemSelected(item);
  }
Esempio n. 10
0
 @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;
   }
   // 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);//默认的打开浏览器,是www.google.com
       Intent intent = new Intent(Intent.ACTION_VIEW);
       intent.setData(Uri.parse("http://www.baidu.com")); // 指定特定的网址显示
       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);
   }
 }
 // When the button of "Select a Photo in Album" is pressed.
 public void selectImageInAlbum(View view) {
   Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
   intent.setType("image/*");
   if (intent.resolveActivity(getPackageManager()) != null) {
     startActivityForResult(intent, REQUEST_SELECT_IMAGE_IN_ALBUM);
   }
 }
Esempio n. 12
0
 /**
  * Creates an Intent chooser with a gallery Intent and, if available, a camera Intent. If the
  * camera Intent is available, a placeholder file will be created to store the image taken from
  * the camera. This method will then return the chooser Intent along with the URI of the image
  * taken from the camera. If no image was taken, the URI will be null.
  *
  * @param context The current Context used to access the PackageManager and resources
  * @param chooserTitle The title that will be displayed in the chooser Intent
  * @return An object containing both the chooser Intent and the URI of the image taken from the
  *     camera. If no image was taken then the URI will be null.
  */
 public static Pair<Intent, Uri> getCameraAndGalleryIntentChooser(
     Context context, String chooserTitle) {
   // The Pair that will contain the chooser Intent and the URI of the camera file if any
   Pair<Intent, Uri> intentUriPair;
   // Gallery Intent
   Intent galleryIntent = new Intent();
   galleryIntent.setType("image/*");
   galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
   // Intent to prompt the user how they want to get the file
   Intent chooseIntent = Intent.createChooser(galleryIntent, chooserTitle);
   // Camera Intent
   Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
   // Make sure the camera Intent can be used
   if (cameraIntent.resolveActivity(context.getPackageManager()) != null) {
     final File directory =
         Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
     final String filename = Files.getNewUniqueFileNameForCamera();
     File image = new File(directory, filename);
     // Store a reference to the image URI
     Uri outUri = Uri.fromFile(image);
     // Add the output location to the camera Intent
     cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outUri);
     // Create a collection for the camera Intent
     Intent[] cameraIntents = new Intent[] {cameraIntent};
     // Add the camera Intent to the Intent chooser
     chooseIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents);
     // Add the Intent and URI to the Pair
     intentUriPair = new Pair<Intent, Uri>(chooseIntent, outUri);
   } else {
     // Add the Intent to the Pair
     intentUriPair = new Pair<Intent, Uri>(chooseIntent, null);
   }
   return intentUriPair;
 }
Esempio n. 13
0
 private void openTrailer(String url) {
   Uri webpage = Uri.parse(url);
   Intent i = new Intent(Intent.ACTION_VIEW, webpage);
   if (i.resolveActivity(getActivity().getPackageManager()) != null) {
     startActivity(i);
   }
 }
Esempio n. 14
0
  /** This method is called when the order button is clicked. */
  public void submitOrder(View view) {

    CheckBox whippedCreamChekBox = (CheckBox) findViewById(R.id.whipped_cream_checkbox);
    CheckBox chocolat = (CheckBox) findViewById(R.id.chocolat_checkbox);
    EditText name = (EditText) findViewById(R.id.name_EditText);

    String nameString = name.getText().toString();
    boolean haschocolat = chocolat.isChecked();
    boolean hasWhippedcream = whippedCreamChekBox.isChecked();
    // Log.v("MainActivity","check -->"+hasWhippedcream);
    int price = calculatePrice(quantity, hasWhippedcream, haschocolat);
    String priceMessage =
        createOrderSummary(quantity, nameString, price, hasWhippedcream, haschocolat);
    // displayMessage(priceMessage);

    // pour envoyer la facture en email
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/html");
    intent.putExtra(Intent.EXTRA_SUBJECT, "JustJava order for " + nameString);
    intent.putExtra(Intent.EXTRA_TEXT, priceMessage);

    if (intent.resolveActivity(getPackageManager()) != null) {
      startActivity(intent.createChooser(intent, "Send Email"));
    }
  }
  private void openPreferredLocationInMap() {
    // Using the URI scheme for showing a location found on a map.  This super-handy
    // intent can is detailed in the "Common Intents" page of Android's developer site:
    // http://developer.android.com/guide/components/intents-common.html#Maps
    if (null != mForecastAdapter) {
      Cursor c = mForecastAdapter.getCursor();
      if (null != c) {
        c.moveToPosition(0);
        String posLat = c.getString(COL_COORD_LAT);
        String posLong = c.getString(COL_COORD_LONG);
        Uri geoLocation = Uri.parse("geo:" + posLat + "," + posLong);

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(geoLocation);

        if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
          startActivity(intent);
        } else {
          Log.d(
              LOG_TAG,
              "Couldn't call " + geoLocation.toString() + ", no receiving apps installed!");
        }
      }
    }
  }
Esempio n. 16
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   int id = item.getItemId();
   switch (id) {
     case R.id.action_refresh:
       refresh();
       return true;
     case R.id.action_copy_url:
       String copyDone = getString(R.string.tip_copy_done);
       AndroidUtils.copyToClipBoard(this, mWebView.getUrl(), copyDone);
       return true;
     case R.id.action_open_url:
       Intent intent = new Intent();
       intent.setAction(Intent.ACTION_VIEW);
       Uri uri = Uri.parse(mUrl);
       intent.setData(uri);
       if (intent.resolveActivity(getPackageManager()) != null) {
         startActivity(intent);
       } else {
         ToastUtils.showLong(R.string.tip_open_fail);
       }
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
Esempio n. 17
0
  private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    Intent intent = getIntent();

    final DatabaseHandler dbHandler = new DatabaseHandler(getApplicationContext());
    int id = intent.getIntExtra("id", 0);

    // Ensure that there's a camera activity to handle the intent
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
      // Create the File where the photo should go
      // File photoFile = null;
      try {
        photoFile = PhotoHelper.createImageFileForDocument(id, getApplicationContext());

      } catch (IOException ex) {
        // Error occurred wh7ile creating the File

      }

      // Continue only if the File was successfully created
      if (photoFile != null) {
        takePictureIntent.putExtra("output", Uri.fromFile(photoFile));

        // final document_obj doc_obj = new document_obj();
        doc_obj.set_doc_name(photoFile.getPath());
        doc_obj.set_doc_path(photoFile.getPath());
        // bitmap =BitmapFactory.decodeFile(photoFile.getPath());
        // doc_obj.set_bmp(PhotoHelper.getBitmapAsByteArray(bitmap));
        doc_obj.set_id(id);

        startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
      }
    }
  }
Esempio n. 18
0
 public static void openCameraFrom(Fragment fragment, @NonNull File imageFile) {
   Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
   if (takePictureIntent.resolveActivity(fragment.getActivity().getPackageManager()) != null) {
     takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));
     fragment.startActivityForResult(takePictureIntent, CAMERA_REQUEST_CODE);
   }
 }
Esempio n. 19
0
 public void share(View view) {
   Intent intent = new Intent(Intent.ACTION_SEND);
   intent.setType("*/*");
   if (intent.resolveActivity(getPackageManager()) != null) {
     startActivity(intent);
   }
 }
Esempio n. 20
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
    String location =
        sharedPref.getString(
            getString(R.string.pref_location_key), getString(R.string.pref_location_default));
    String unit =
        sharedPref.getString(
            getString(R.string.pref_units_key), getString(R.string.pref_units_imperial));
    Intent intent = null;

    // Handle item selection
    switch (item.getItemId()) {
      case R.id.action_refresh:
        FetchWeatherTask task = new FetchWeatherTask();
        task.execute(location, unit);
        return true;
      case R.id.action_map_location:
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("geo:0,0?q=" + location));
        if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
          startActivity(intent);
        }
        return true;
      case R.id.action_settings:
        intent = new Intent(getActivity(), SettingsActivity.class);
        startActivity(intent);
        return super.onOptionsItemSelected(item);
      default:
        return super.onOptionsItemSelected(item);
    }
  }
Esempio n. 21
0
 /**
  * Check the {@link PackageManager} if the phone has an application installed to view this type of
  * attachment. If not, {@link #viewButton} is disabled. This should be done in any place where
  * attachment.viewButton.setEnabled(enabled); is called. This method is safe to be called from the
  * UI-thread.
  */
 public void checkViewable() {
   if (viewButton.getVisibility() == View.GONE) {
     // nothing to do
     return;
   }
   if (!viewButton.isEnabled()) {
     // nothing to do
     return;
   }
   try {
     Uri uri = AttachmentProvider.getAttachmentUriForViewing(mAccount, part.getAttachmentId());
     Intent intent = new Intent(Intent.ACTION_VIEW);
     intent.setData(uri);
     intent.addFlags(
         Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
     if (intent.resolveActivity(mContext.getPackageManager()) == null) {
       viewButton.setEnabled(false);
     }
     // currently we do not cache re result.
   } catch (Exception e) {
     Log.e(
         K9.LOG_TAG,
         "Cannot resolve activity to determine if we shall show the 'view'-button for an attachment",
         e);
   }
 }
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Trailer tempTrailer = null;
    if (trailers != null && trailers.size() > 0) {
      tempTrailer = trailers.get(position);
    }
    if (tempTrailer != null) {
      // Invoke youtube
      String youtubeURL = AppConstants.MOVIE_YOUTUBE_URL + "/" + tempTrailer.getTrailerKey();

      Uri uri = null;
      try {
        uri = Uri.parse(youtubeURL).buildUpon().build();
      } catch (Exception e) {
        Log.e(TAG, e.getMessage());
      }
      if (uri != null) {
        // Log.v(TAG, "Video URI " + uri.toString());
        Intent intent = new Intent(Intent.ACTION_VIEW);
        // intent.setDataAndType(uri, "video/*");
        intent.setData(uri);
        if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
          startActivity(intent);
        }

      } else {
        Toast.makeText(getActivity(), "Some problem with the video", Toast.LENGTH_SHORT).show();
      }
    }
  }
  public void actionImage() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
      // Create the File where the photo should go
      File photoFile = null;
      try {
        photoFile = gallery_data.createImageFile();
        mCurrentPhotoPath = null;
        // Continue only if the File was successfully created
        if (photoFile != null) {
          mCurrentPhotoPath = photoFile.getAbsolutePath();

          takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
          startActivityForResult(takePictureIntent, ConstantsUtils.REQUEST_TAKE_PHOTO);
        } else {
          Toast.makeText(
                  getActivity().getApplicationContext(),
                  R.string.msg_camera_error_file,
                  Toast.LENGTH_LONG)
              .show();
        }
      } catch (IOException e) {
        // Error occurred while creating the File
        StringBuffer msg_error =
            new StringBuffer()
                .append(getResources().getString(R.string.msg_camera_error_file))
                .append("[")
                .append(e.getMessage())
                .append("]");
        Toast.makeText(
                getActivity().getApplicationContext(), msg_error.toString(), Toast.LENGTH_LONG)
            .show();
      }
    }
  }
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference == mReboot) {
      PowerManager pm = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE);
      pm.reboot("Resetting density");
      return true;

    } else if (preference == mClearMarketData) {

      new ClearMarketDataTask().execute("");
      return true;

    } else if (preference == mRebootClearData) {
      PowerManager pm = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE);
      pm.reboot("Clear market data");
      return true;

    } else if (preference == mOpenMarket) {
      Intent openMarket =
          new Intent(Intent.ACTION_MAIN)
              .addCategory(Intent.CATEGORY_APP_MARKET)
              .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      ComponentName activityName = openMarket.resolveActivity(getActivity().getPackageManager());
      if (activityName != null) {
        mContext.startActivity(openMarket);
      } else {
        preference.setSummary(
            getResources().getString(R.string.open_market_summary_could_not_open));
      }
      return true;
    }

    return super.onPreferenceTreeClick(preferenceScreen, preference);
  }
  // Take photo
  public void takePhoto() {
    Context context = getActivity();
    PackageManager packageManager = context.getPackageManager();

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(packageManager) != null)
      startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
  }
Esempio n. 26
0
 public void open_google(View view) {
   String url = "http://www.google.com";
   Intent intent = new Intent(Intent.ACTION_VIEW);
   intent.setData(Uri.parse(url));
   if (intent.resolveActivity(getPackageManager()) != null) {
     startActivity(intent);
   }
 }
Esempio n. 27
0
 public void open_maps(View view) {
   Uri geoLocation = Uri.parse("google.streetview:cbll=46.414382,10.013988");
   Intent intent = new Intent(Intent.ACTION_VIEW, geoLocation);
   intent.setPackage("com.google.android.apps.maps");
   if (intent.resolveActivity(getPackageManager()) != null) {
     startActivity(intent);
   }
 }
Esempio n. 28
0
 public void openWebPage(String url) {
   Uri webpage = Uri.parse(url);
   Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
   intent.setData(webpage);
   if (intent.resolveActivity(getPackageManager()) != null) {
     startActivity(intent);
   }
 }
  private void dispatchTakePictureIntent() {
    //  Log.i(TAG, "Opening Camera app to take the picture...");

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
      startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
    }
  }
Esempio n. 30
0
 private void startApplicationDetailsActivity(String packageName) {
   Intent intent =
       new Intent(
           Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
           Uri.fromParts("package", packageName, null));
   intent.setComponent(intent.resolveActivity(mContext.getPackageManager()));
   TaskStackBuilder.create(getContext()).addNextIntentWithParentStack(intent).startActivities();
 }