Created
June 30, 2017 09:37
-
-
Save vtthach/bee7a746f23c24c6a0c658821cad46d0 to your computer and use it in GitHub Desktop.
Select photo camera intent utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.piing.util; | |
import android.app.Activity; | |
import android.content.Intent; | |
import android.net.Uri; | |
import android.provider.MediaStore; | |
import com.piing.AppConstant; | |
import com.piing.R; | |
import java.io.File; | |
/** | |
* Created by Thach.Vo on 7/23/2015. | |
*/ | |
public class PhotoUtils { | |
public static Uri startIntentCamera(Activity act) { | |
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
File f = new File(android.os.Environment.getExternalStorageDirectory(), String.format("piing_image_tmp_%d.jpg", System.currentTimeMillis())); | |
Uri mOutputUri = Uri.fromFile(f); | |
intent.putExtra(MediaStore.EXTRA_OUTPUT, mOutputUri); | |
act.startActivityForResult(intent, AppConstant.REQUEST_CODE.REQUEST_CODE_TAKE_IMAGE); | |
return mOutputUri; | |
} | |
public static void startIntentGallery(Activity act) { | |
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); | |
intent.setType("image/*"); | |
act.startActivityForResult(Intent.createChooser(intent, act.getString(R.string.user_setting_complete_sd_card)), AppConstant.REQUEST_CODE.REQUEST_CODE_PICKUP_IMAGE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment