Giter Club home page Giter Club logo

imagepicker's People

Contributors

andybdahl avatar beta avatar bkhezry avatar boss1088 avatar brainsucker avatar dattran-pt19 avatar kishanviramgama avatar nguyenhoanglam avatar nubpro avatar rainer-lang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imagepicker's Issues

Problem with Jitpack

Hi everyone!

Currenly, I use Jitpack to release a new version. In version 1.0.1 and 1.0.2, everything works well. Now I have a problem when releasing version 1.0.3:

  • First, I created a tag named "1.0.3" on Github, you can check it here
  • Then I go to Jitpack and it generated a gradle dependency of version 1.0.3:

compile 'com.github.nguyenhoanglam:ImagePicker:1.0.3'

However, when I add this dependency to Android Studio project, the library does not contain the new source code in Github's source code. It's still the same code in version 1.0.2.

I'm not proficient in Git. Please help me!

Crash while taking photo using camera.

while cheking in kitkat. i found an issue when i clicked photo using camera it shows double photos with same capture. and another issue is my application is crashed while taking picture in camera(in LOLLIPOP).

URGENT: Update Glide to v4.0.0

This library is NOT compatible with people using Glide v4.0.0 as a dex error occurs. The error is due to this library using Glide v3.7 while the latest version is v4.0.0.

Please merge PR #58 which solves this issue. Thank you!

App closed on launching Image Picker code

My Code

ImagePicker.create(this)
.folderMode(true) // folder mode (false by default)
.folderTitle("Folder") // folder selection title
.imageTitle("Tap to select") // image selection title
.single() // single mode
.showCamera(true) // show camera or not (true by default)
.start(123456); // start image picker activity with request code

Getting this error..

Error 1) Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v7.widget.Toolbar

Error 2) Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 13: TypedValue{t=0x2/d=0x7f010082 a=-1}
at android.content.res.TypedArray.getDrawable(TypedArray.java:867)
at android.view.View.(View.java:3951)
at android.view.ViewGroup.(ViewGroup.java:573)
at android.view.ViewGroup.(ViewGroup.java:569)
at android.support.v7.widget.Toolbar.(Toolbar.java:235)
at android.support.v7.widget.Toolbar.(Toolbar.java:231)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:941) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:831) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) 
at com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity.onCreate(ImagePickerActivity.java:119) 
at android.app.Activity.performCreate(Activity.java:6245) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5443) 

NullPointerException

Hi! I noticed exception, when after take picture i press ok button, and app stop running and write below:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Message android.os.Handler.obtainMessage()' on a null object reference at com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity$ImageLoaderRunnable.run(ImagePickerActivity.java:545) at java.lang.Thread.run(Thread.java:818)

Provider authority is not different on different build variants

This is how you defined your file provider in Manifest.xml:

<provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="@string/shared_file_provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths" />
        </provider>

This line is problematic:

android:authorities="@string/shared_file_provider"

It is important that defined authority is different for different build variants. Your solution hardcodes it to a single value, which is the same for different build variants. Any app that has multiple build variants and uses your library will get this error when trying to install multiple variants on a single device: Stack Overflow Issue

For a solution, Firebase Manifest.xml is a good example:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.google.firebase">
    <uses-sdk android:minSdkVersion="9" />
    <application>

        <provider
            android:authorities="${applicationId}.firebaseinitprovider"
            android:name=".provider.FirebaseInitProvider"
            android:exported="false"
            android:initOrder="100" />
    </application>
</manifest>

Error when returning to ImagePicker from landscape camera

Hi,

I have a SONY Xperia Z5 which the camera is default in landscape mode.

After I took a picture from the camera app and return to the picker, the picker became landscape too, even I am holding my phone up right.

Then I shake a bit my phone trying to make the picker back to portrait. The following error was found.

java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Message android.os.Handler.obtainMessage()' on a null object reference
at com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity$ImageLoaderRunnable.run(ImagePickerActivity.java:545)
at java.lang.Thread.run(Thread.java:818)

ImagePickerActivity NullPointerException

Got this from fabric:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Message android.os.Handler.obtainMessage()' on a null object reference
at com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity$ImageLoaderRunnable.run(ImagePickerActivity.java:755)
at java.lang.Thread.run(Thread.java:818)

Here's my code:

if (requestCode == RC_CHANGE_IMAGE && resultCode == RESULT_OK && data != null) {
            ArrayList<Image> images = data.getParcelableArrayListExtra(ImagePickerActivity.INTENT_EXTRA_SELECTED_IMAGES);
            Image image = images.size() == 0 ? null : images.get(0);
            if (image != null) {
                Bitmap bitmap = ImageUtils.getScaledBitmap(image.getPath(), 720);
                imgProfile.setImageBitmap(bitmap);
                pictureImage = saveFile(bitmap);
            }
        }

Info about selecting a single photo

Please i want to select just one single photo and return it's result in ImageView instead of returning it's path

the main issue is that i can't replace the array of images or strings in a single one can you please assist ?

Thank you :)

ConcurrentModificationException

java.util.ConcurrentModificationException
at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573)
at com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity$5.handleMessage(ImagePickerActivity.java:602)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Camera Error

I am using 1.1.2 and the camera error is still there. When I try to take picture from camera the app crashes. How to solve it? I am trying it into API 17

Images stay selected

Images once selected stay selected after i exit from my app. How do i set them to deselect after i click add?

Camera crash issue

Hello! I am getting issue when I try to make photo by camera
here is error log

FATAL EXCEPTION: main
Process: ru.knamauto.droid, PID: 1481
java.lang.RuntimeException: Unable to resume activity {ru.knamauto.droid/com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2000, result=-1, data=null} to activity {ru.knamauto.droid/com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity}: java.lang.NullPointerException: uriString
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3232)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3263)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2606)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2000, result=-1, data=null} to activity {ru.knamauto.droid/com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity}: java.lang.NullPointerException: uriString
at android.app.ActivityThread.deliverResults(ActivityThread.java:3839)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3214)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3263) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2606) 
at android.app.ActivityThread.access$800(ActivityThread.java:178) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loop(Looper.java:194) 
at android.app.ActivityThread.main(ActivityThread.java:5637) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754) 
Caused by: java.lang.NullPointerException: uriString
at android.net.Uri$StringUri.(Uri.java:470)
at android.net.Uri$StringUri.(Uri.java:460)
at android.net.Uri.parse(Uri.java:432)
at com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity.onActivityResult(ImagePickerActivity.java:520)
at android.app.Activity.dispatchActivityResult(Activity.java:6294)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3835)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3214) 
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3263) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2606) 
at android.app.ActivityThread.access$800(ActivityThread.java:178) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loop(Looper.java:194) 
at android.app.ActivityThread.main(ActivityThread.java:5637) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754) 

Failure [INSTALL_FAILED_CONFLICTING_PROVIDER]

Hello!
When trying to use the library with 2 different apps, getting this error during installation:
pkg: /data/local/tmp/com.company.application
Failure [INSTALL_FAILED_CONFLICTING_PROVIDER]
As i know, the use is connected to authorities. But i really can't get how to cope with it.
Please, can you help me? Thanks

Crash when using camera

i am using your lattest library compile 'com.github.nguyenhoanglam:ImagePicker:1.1.1'
when i use camera option it gives concurent modification exception can u please help me to tackle that
: Exception
Process: com.example.invision.driverapplication, PID: 21913
java.util.ConcurrentModificationException
at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573)
at com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity$5.handleMessage(ImagePickerActivity.java:602)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5456)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

Looks like your .gitignore still pass extra files in repository

.gradle/2.10
.idea
build/generated
local.properties
imagepicker/build
etc

But you can try mine:

# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# Intellij
.idea/
*.iml

# Keystore files
*.jks

# OS-specific files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

Prepare for new release

Hi everyone! (@maxotov @khemmachattk @prsnt @codevalley @Hitexroid)

Thanks for supporting the library!
In the past week, I'm trying to fix bugs that you reported including camera crash, not return data and add folder mode. So I need all of your help to test fix_album_mode branch before releasing it. If you find bugs, please comment in this issue!
Please check the sample app for new features!

Thanks very much!

Working With Fragment

I have issues using this library with fragments. The result isn't returned even though the host activity has a

super.onActivityResult(requestCode, resultCode, data);

in it's onActivityResult method which is also overrode in the fragment to do the necessary manipulation

Please help

I want to get the picture directly after taking picture from the camera.

if i am selecting the option to take a picture from camera and then it just take the picture and then i have to select the picture from the gallery. so i want to just get the picture returned after i take the picture from the camera. i dont want to select the same picture after i take that picture. please suggest a solution.

Crash Crash with Camera

E/AndroidRuntime: FATAL EXCEPTION: Thread-1217
Process: com.modize.digicard, PID: 29429
java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Message android.os.Handler.obtainMessage()' on a null object reference
at com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity$ImageLoaderRunnable.run(ImagePickerActivity.java:545)
at java.lang.Thread.run(Thread.java:818)

Camera Error

FATAL EXCEPTION: main
Process: galaxy.tech.mobileexchangeradmin, PID: 24976
java.lang.IllegalThreadStateException: Thread already started
at java.lang.Thread.checkNotStarted(Thread.java:849)
at java.lang.Thread.start(Thread.java:1059)
at com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity.getData(ImagePickerActivity.java:345)
at com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity.access$1400(ImagePickerActivity.java:58)
at com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity$6.onChange(ImagePickerActivity.java:624)
at android.database.ContentObserver.onChange(ContentObserver.java:130)
at android.database.ContentObserver.onChange(ContentObserver.java:145)
at android.database.ContentObserver$NotificationRunnable.run(ContentObserver.java:216)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5624)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)

Getting Error when pressing back button in Picture chooser activity [when no image is selected]

08-16 05:05:26.330 24320-24320/yasirameen.com.googlemapdemo E/AndroidRuntime: FATAL EXCEPTION: main Process: yasirameen.com.googlemapdemo, PID: 24320 java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1000, result=0, data=null} to activity {yasirameen.com.googlemapdemo/invision.app.facebookclassified.activities.TimeLineActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.ArrayList android.content.Intent.getParcelableArrayListExtra(java.lang.String)' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:3539) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3582) at android.app.ActivityThread.access$1300(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1327) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.ArrayList android.content.Intent.getParcelableArrayListExtra(java.lang.String)' on a null object reference at invision.app.facebookclassified.activities.TimeLineActivity.onActivityResult(TimeLineActivity.java:376) at android.app.Activity.dispatchActivityResult(Activity.java:6135) at android.app.ActivityThread.deliverResults(ActivityThread.java:3535) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3582)  at android.app.ActivityThread.access$1300(ActivityThread.java:144)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1327)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5221)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)  08-16 05:05:28.431 24320-24320/yasirameen.com.googlemapdemo I/Process: Sending signal. PID: 24320 SIG: 9

Imagepicker doesn't return result on second call.

I am using imagepicker activity in the following way.

ImagePicker.create(ComposeActivity.this)
           .single() 
           .showCamera(true) 
           .start(INTENT_REQUEST_GET_IMAGES); 

This same structure is used in a few activities.
When I call this for the first time, it works perfectly. On second call, (either from the same activity or different one), the onActivityResult() is not called. It works again when you kill and start the app.
Tested on multiple devices running Marshmallow.

Not working

It is not working? and it is not clear.

How can I set imageview this
ArrayList<Image> images = data.getParcelableArrayListExtra(ImagePickerActivity.INTENT_EXTRA_SELECTED_IMAGES);
??

Why do not you explain?? It is the most important thing and explaining should not be hard but you did not explain why?

Selected images can't come in result activity

I have two activity one of them list of item and one adding item activity. In adding item activity i call your ImagePickerActitvity to select images. Then ImagePickerActivity when i select images and push add button, in my activity doesn't come any response. This is problem occured, i guess when in adding item activity press back button to list of item activity. Then i open adding activity again, this problem occured.

Crashes the Samsung S4 Mini camera after taking the photo in 1.1.3, android version 4.2.2 (catlog incl.)

It crashes the Samsung S4 Mini camera after taking the photo in 1.1.3 android version 4.2.2. The viewfinder continues to be active for about 4 seconds more after pressing the take photo button and then finally freezes. The picture (from point of capture not where viewfinder freezes) arrives in the gallery though but only after "Unfortunately, Camera has stopped" message, it is a guaranteed crash on every try. (works ok on S6 edge). I crashed it 3 times and can see 3 fatal exceptions in the attached log cat but logs are new to me, so unsure of cause/fix.
logcat.txt

Need More Help ....

Hey nguyenhoanglam,

Thank you for all the help you provided me.

I want to ask one thing if you don't mind.
When taking picture using your library from camera, its first appear in gallery then we select it to be use.

Now i want it to be like , " after taking picture from camera its selected in activity results"

more clearly, like facebook does when take picture from camera.

Millions of thanks

Urgent : App Crashing due to - java.lang.NullPointerException: uriString

Hello ,

Thanks for such a nice library. Really like this.

I want to select only single image. I clicked camera, captured photo, but i am getting null result so app is crashing.

Code:

ImagePicker.create(this)
.folderMode(true) // set folder mode (false by default)
.folderTitle("Folder") // folder selection title
.imageTitle("Tap to select") // image selection title
.single() // single mode
.showCamera(true) // show camera or not (true by default)
.imageDirectory("Camera") // captured image directory name ("Camera" folder by default)
.origin(null) // original selected images, used in multi mode
.start(12345); // start image picker activity with request code

Error :

Caused by: java.lang.NullPointerException: uriString
at android.net.Uri$StringUri.(Uri.java:475)
at android.net.Uri$StringUri.(Uri.java)
at android.net.Uri.parse(Uri.java:437)
at com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity.onActivityResult(ImagePickerActivity.java:520)
at android.app.Activity.dispatchActivityResult(Activity.java:6442)

Captured image not showing only in Samsung galaxy s4

After going through so many blog and hints i didnt found solution. I want to show captured image in android image view. Below you can find the code i am using to capture an image from camera.
Please provide the solution that will work for all the devices.

private void onLaunchCamera() {

    // create Intent to take a picture and return control to the calling application
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    filepath1 = FileProvider.getUriForFile(MainActivity.this, BuildConfig.APPLICATION_ID + ".provider", getPhotoFileUri(photofileName));
    intent.putExtra(android.content.Intent.EXTRA_STREAM, filepath1); // set the image file name
    // If you call startActivityForResult() using an intent that no app can handle, your app will crash.
    // So as long as the result is not null, it's safe to use the intent.
    if (intent.resolveActivity(getPackageManager()) != null) {
        // Start the image capture intent to take photo
        startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
    }

}

private File getPhotoFileUri(String photofileName) {

    // Only continue if the SD Card is mounted
    if (isExternalStorageAvailable()) {
        // Get safe storage directory for photos
        // Use `getExternalFilesDir` on Context to access package-specific directories.
        // This way, we don't need to request external read/write runtime permissions.
        File mediaStorageDir = new File(
                getExternalFilesDir(Environment.DIRECTORY_PICTURES), APP_Name);
        // Create the storage directory if it does not exist
        if (!mediaStorageDir.exists() && !mediaStorageDir.mkdirs()) {
            Log.d(APP_Name, "failed to create directory");
        }
       imagefilepath = "content:"+mediaStorageDir.getPath()+photofileName;
        return (new File(mediaStorageDir.getPath() + File.separator + photofileName));
        // Return the file target for the photo based on filename

    }
    return null;


}

/**
 * It will check if SD card is mounted to the view or not.
 *
 * @return
 */
private boolean isExternalStorageAvailable() {
    String state = Environment.getExternalStorageState();
    return state.equals(Environment.MEDIA_MOUNTED);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Uri photoUri = null;
    Bitmap bm;

    if (resultCode == RESULT_OK) {
        if (data != null) {


            photoUri=data.getData();
            Log.d("selectedimage", ""+photoUri);
            String[] filePath = { MediaStore.Images.Media.DATA };
            Cursor c = getContentResolver().query(photoUri,filePath, null, null, null);
            c.moveToFirst();
            int columnIndex = c.getColumnIndex(filePath[0]);
            String picturePath = c.getString(columnIndex);
            c.close();
            Bitmap thumbnail = (BitmapFactory.decodeFile(picturePath));
        
              m_Imagebutton.setImageBitmap(thumbnail);
        }
    }
}

Thanks in advance.

Android Nougat 7.0 camera problem

When I open camera, it just crash.

android.os.FileUriExposedException: file:///storage/emulated/0/Pictures/Camera/IMG_20160816_135126.jpg exposed beyond app through ClipData.Item.getUri()

Getting below error.

java.lang.NoSuchFieldError: No static field menu_add of type I in class Lcom/nguyenhoanglam/imagepicker/R$id; or its superclasses (declaration of 'com.nguyenhoanglam.imagepicker.R$id' appears in /data/data/com.trinityholisticsolutions.poojamedimart/files/instant-run/dex/slice-slice_6-classes.dex)
at com.nguyenhoanglam.imagepicker.activity.ImagePickerActivity.onCreateOptionsMenu(ImagePickerActivity.java:145)
at android.app.Activity.onCreatePanelMenu(Activity.java:2850)
at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:358)
at android.support.v7.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:88)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.onCreatePanelMenu(AppCompatDelegateImplBase.java:270)
at android.support.v7.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:88)
at android.support.v7.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:454)
at android.support.v7.app.ToolbarActionBar$1.run(ToolbarActionBar.java:61)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.