Intent setType - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Intent setType method.

This code example shows how to use the following methods:setType
     * picture from it. 
     *  
     * @return the intent 
     */ 
    public static Intent newSelectPictureIntent() {
        Intent intent = new Intent(Intent.ACTION_PICK);
        intent.setType("image/*");
        return intent;
    } 
 
    /** 
     * Creates an intent that will open the phone app and enter the given number. Unlike 
     * {@link #newCallNumberIntent(String)}, this does not actually dispatch the call, so it gives 
     * the user a chance to review and edit the number. 
     *  
     * @param phoneNumber 
     *            the number to dial 
     * @return the intent 
     */ 
    public static Intent newDialNumberIntent(String phoneNumber) {
7
CodeRank
This code example shows how to use the following methods:putExtra, setType
	} 
	 
	private static Intent createSendIntent(String subject, String body, SendLogDetails.AttachmentType attachmentType, File attachment) {
		 
		String action = android.content.Intent.ACTION_SEND;
		Intent actionSendIntent = new Intent(action);
 
		actionSendIntent.setType(attachmentType.getMimeType());
		actionSendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
		if (!TextUtils.isEmpty(body)) {
			actionSendIntent.putExtra(Intent.EXTRA_TEXT, body);
		} 
		if (attachment != null) {
			Uri uri = Uri.fromFile(attachment);
			log.d("uri is: %s", uri);
			actionSendIntent.putExtra(Intent.EXTRA_STREAM, uri);
		} 
		 
		return actionSendIntent;
	} 
	 
7
CodeRank
This code example shows how to use the following methods:setType
     *     stored by the content-provider. 
     *     {@link PhotoSelectionHandler#handlePhotoActivityResult(int, int, Intent)}. 
     */ 
    private void startPickFromGalleryActivity(String photoFile) {
        final Intent intent = getPhotoPickIntent(photoFile);
        startPhotoActivity(intent, REQUEST_CODE_PHOTO_PICKED_WITH_DATA, photoFile);
    } 
 
    private int getPhotoPickSize() { 
        // Note that this URI is safe to call on the UI thread. 
        Cursor c = mContext.getContentResolver().query(DisplayPhoto.CONTENT_MAX_DIMENSIONS_URI,
                new String[]{DisplayPhoto.DISPLAY_MAX_DIM}, null, null, null);
        try { 
            c.moveToFirst();
            return c.getInt(0);
        } finally { 
            c.close();
        } 
    } 
 

7
CodeRank
This code example shows how to use the following methods:putExtra, setType
     * Creates a sharing {@link Intent}. 
     * 
     * @return The sharing intent. 
     */ 
    private Intent createShareIntent() {
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("image/*");
        Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
        return shareIntent;
    } 
 
    /** 
     * Copies a private raw resource content to a publicly readable 
     * file such that the latter can be shared with other applications. 
     */ 
    private void copyPrivateRawResuorceToPubliclyAccessibleFile() { 
        InputStream inputStream = null;
        FileOutputStream outputStream = null;
        try { 
7
CodeRank
This code example shows how to use the following methods:createChooser, setType
        button.setOnClickListener(mGetMusicListener);
    } 
 
    private OnClickListener mGetMusicListener = new OnClickListener() {
        public void onClick(View v) { 
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
            intent.setType("audio/*"); 
            startActivity(Intent.createChooser(intent, "Select music")); 
        } 
    }; 
} 
7
CodeRank
This code example shows how to use the following methods:setType
     * picture from it. 
     *  
     * @return the intent 
     */ 
    public static Intent newSelectPictureIntent() {
        Intent intent = new Intent(Intent.ACTION_PICK);
        intent.setType("image/*");
        return intent;
    } 
 
    /** 
     * Creates an intent that will open the phone app and enter the given number. Unlike 
     * {@link #newCallNumberIntent(String)}, this does not actually dispatch the call, so it gives 
     * the user a chance to review and edit the number. 
     *  
     * @param phoneNumber 
     *            the number to dial 
     * @return the intent 
     */ 
    public static Intent newDialNumberIntent(String phoneNumber) {
7
CodeRank
This code example shows how to use the following methods:setAction, setType
        telop.setTypeface(Typeface.DEFAULT, 1);
        mFrameLayout.addView(telop);
    } 
 
    public void onPickVideoButton(View view) {
        Intent intent = new Intent();
        intent.setType("video/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(intent, 1);
    } 
 
    protected void onActivityResult(int requestCode,
                                    int resultCode, Intent data) {
        if (resultCode == RESULT_OK && requestCode == 1) {
            Uri uri = data.getData();
            mVideoView.setVideoURI(uri);
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:putExtra, setType
            finish();
        } 
 
        // TODO: get these values from constants somewhere 
        // TODO: Adjust the PhotoFrame's image size to avoid on the fly scaling 
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
        intent.setType("image/*");
        intent.putExtra("crop", "true");
        intent.putExtra("aspectX", 1);
        intent.putExtra("aspectY", 1);
        intent.putExtra("outputX", 192);
        intent.putExtra("outputY", 192);
        intent.putExtra("noFaceDetection", true);
        intent.putExtra("return-data", true);
 
        startActivityForResult(intent, REQUEST_GET_PHOTO);
    } 
 
    @Override 
    public void onPause() { 
7
CodeRank
This code example shows how to use the following methods:putExtra, setType
		doShare(); 
		return true; 
	} 
 
	public void doShare() { 
		Intent intent = new Intent(Intent.ACTION_SEND);
		intent.setType("text/plain");
		intent.putExtra(Intent.EXTRA_TEXT, "Message");
		provider.setShareIntent(intent);
	} 
} 
7
CodeRank
This code example shows how to use the following methods:getAction, getType, setType
        } 
    } 
 
    private void initializeByIntent() { 
        Intent intent = getIntent();
        String action = intent.getAction();
 
        if (Intent.ACTION_GET_CONTENT.equalsIgnoreCase(action)) {
            startGetContent(intent);
        } else if (Intent.ACTION_PICK.equalsIgnoreCase(action)) {
            // We do NOT really support the PICK intent. Handle it as 
            // the GET_CONTENT. However, we need to translate the type 
            // in the intent here. 
            Log.w(TAG, "action PICK is not supported");
            String type = Utils.ensureNotNull(intent.getType());
            if (type.startsWith("vnd.android.cursor.dir/")) {
                if (type.endsWith("/image")) intent.setType("image/*");
                if (type.endsWith("/video")) intent.setType("video/*");
            } 
            startGetContent(intent);

8
CodeRank

Related Intent setType Questions & Answers:

Other Intent setType Examples

27:	  public void pickImage(View View) {
28:	    Intent intent = new Intent();
29:	    intent.setType("image/*");
30:	    intent.setAction(Intent.ACTION_GET_CONTENT);
31:	    intent.addCategory(Intent.CATEGORY_OPENABLE);

Read More

setType Method Overview
Set an explicit MIME data type.
See Code Examples for other Android Intent Methods: