A library to take picture easy, transform your data in different format and save photos in your device

Overview

alt tag

A Magic library to take photos and select pictures in Android. In a simple way and if you need it also save the pictures in device, and facial recognition, get the real uri path or the photo or obtain the private information of the picture.
Android Arsenal Codacy Badge License


Get it on Google Play

Contents

Features


Buy me a Coffee (Donate)

How to Start


Photo Features and permissions


Footer Docs




Features MagicalCamera.

  • Take picture with camera device.

  • Select pictures in gallery device (read in devices).

  • Write the pictures that you taken in device, in your own directory.

  • Return the path of your photo in device. (This issue is solved for @arthursz)

  • RealTime Permissions Magical camera offers a simple integration of realtime permissions. (This functionallity is created by @cutiko)

  • Working in android 6.0 (We have a class to request the user permission).

  • Create yours standards of name of pictures, or use our standard, like "photoname_YYYYmmddHHmmss"

  • Posibility of shown the private info photography, like latitude, longitude, ISO or others with Exif Class.

  • Posibility of rotate picture when it's required.

  • Select the quality of the photo with a percentage, when 1 is the worst and 100 is the better.

  • Obtain the LandMark and return a bitmap with a facial recognition that you need.

  • Return the BitmapPhoto if you need to save this in internal DB of your application.

  • Convert your bitmap in array bytes or string64, if you need to send by Json or XML.

  • Type of photo formats: PNG, JPEG and WEBP.

Other Features

  • A library completely OpenSource.
  • Use best practice in POO
  • Minimun SDK 14+ API.
  • Support library
  • Compile with Gradle
  • License Under Apache 2.0
  • The easiest possible integration
  • Integrate in less than 5 minutes
  • Quick and simple API
  • A good Internal Documentation


Donate

Donate




Getting Started

Download Sources

use git (sourcetree or others) Remember Download the example for understand better the process

git clone https://github.com/fabian7593/MagicalCamera.git

Download from Here

Another type download by Bintray from Download


Setup

Add dependecies

If you need to take photo or select picture, this is your solution. This library give a magical solution for take a picture,write and red in device, return your uri real path and obtain yhe private info of the photo and facial recognition, you only need to download this and integrate this in your project, maybe downloading it or import in your gradle, like this.

repositories {
    jcenter()
}

dependencies {
    compile 'com.frosquivel:magicalcamera:6.0.0'
}

If you have any problem with this dependence, because the library override any styles, colors or others, please change the last line for this code:

 compile('com.frosquivel:magicalcamera:6.0.0@aar') {
        transitive = false;
    }

How To use


Import library

You need to import the library

import com.frosquivel.magicalcamera.MagicalCamera;
import com.frosquivel.magicalcamera.Functionallities.PermissionGranted;

//and maybe you need in some ocations
import com.frosquivel.magicalcamera.Objects.MagicalCameraObject;

Extends Application Class

You need to extends MagicalCamera application

public class MyApplicationClass extends MagicalCameraApplication {
    @Override
    public void onCreate() {
        super.onCreate();
    }
    
    //IF YOU NEED MULTIDEX, SET HERE, NOT ON APPLICATION TAG ON MANIFEAST, LIKE THIS
    @Override
    protected void attachBaseContext(Context base) {
      super.attachBaseContext(base);
      MultiDex.install(this);
    }
}

On manifest, change the name, for the name of your Application class, like this:

  <application
        android:name=".MyApplicationClass">

Permissions on real time

With the MagicalPermissions class you can ask for permissions in a Activity or in an Fragment. This class will take care of validating the device API level, what permissions the user haven't granted yet, ask for thoose permissions, deliver the result and together with MagicalCamera will take the photo or select it from the gallery.

Requesting permissions on real time to the user is a 2 part process. First permissions most be requested, then the result is delivered. So you need a field variable to later call it again on the permissions result:

private MagicalPermissions magicalPermissions;

MagicalPermissions constructor accept two params, the first is the Activity or Fragment and the second is a String array of the permissions you need String[]. MagicalPermissions use the Activity or Fragment to later deliver the result of the permission, and the array to ask for thoose permissions.

magicalPermissions = new MagicalPermissions(this, permissions);

Inside MagicalPermissions it will be solved if the API level of the device requiere to ask permissions or not. If permissions must be asked to the user then MagicalPermissions will validate which permissions are already granted and only asked for the needed. This is why is very important you only ask for the permissions you need, taking the photo or selecting it will only happen if every permission you have asked is granted.

  • By example, if you only need to take the photo then:
String[] permissions = new String[] {
                Manifest.permission.CAMERA
        };
magicalPermissions = new MagicalPermissions(this, permissions);
  • MagicalCamera take care of saving the photo commonly you will need:
String[] permissions = new String[] {
            Manifest.permission.CAMERA,
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE
    };
magicalPermissions = new MagicalPermissions(this, permissions);
  • Or maybe you want to use more potential of MagicalCamera and also ask for location related info, then you need:
String[] permissions = new String[] {
            Manifest.permission.CAMERA,
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE,
            Manifest.permission.ACCESS_COARSE_LOCATION,
            Manifest.permission.ACCESS_FINE_LOCATION
    };
magicalPermissions = new MagicalPermissions(this, permissions);

You can also ask for other permissions in other places of your app, even unrelated to MagicalCamera using MagicalPermissions separatedly. So if getting location information is not requiered for the photo, but is a plus, you should consider separating thoose permissions from the absolutely needed to your feature. MagicalPermissions use a Runnable to do whatever you want after checking the permissions. When is used along with MagicalCamera you don't have to be aware of that, is automatic, but in this case we are considering asking for other permissions:

String[] location = new String[] {
            Manifest.permission.ACCESS_COARSE_LOCATION,
            Manifest.permission.ACCESS_FINE_LOCATION
    };
locationPermissions = new MagicalPermissions(this, location);


Runnable runnable = new Runnable() {
    @Override
    public void run() {
        //TODO location permissions are granted code here your feature
        Toast.makeText(context, "Thanks for granting location permissions", Toast.LENGTH_LONG).show();
    }
};
locationPermissions.askPermissions(runnable);

Then the second part of the process come into play: receiving the permissions result. You have to always override the onRequestPermissionsResult method in the Activity or Fragment. Inside of it, call your instance of MagicalPermissions and give it the result to the permissionResult() method (this is why must be a field). The permissionResult() method is a Map<String, Boolean> in case you need to know what happened and do something about it:

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    Map<String, Boolean> map = magicalPermissions.permissionResult(requestCode, permissions, grantResults);
    for (String permission : map.keySet()) {
        Log.d("PERMISSIONS", permission + " was: " + map.get(permission));
    }
    //Following the example you could also
    //locationPermissions(requestCode, permissions, grantResults);
}

Photo

Declare variable to resize photo

( with pixels percentage ) You need to declare and constant or a simple int variable for the quality of the photo, while greater be, greater be the quality, and otherwise, worst be the quality, like this

//The pixel percentage is declare like an percentage of 100, if your value is 50, the photo will have the middle quality of your camera. 
// this value could be only 1 to 100.
private int RESIZE_PHOTO_PIXELS_PERCENTAGE = 80;

Instance Class MagicalCamera

YOU NEED TO INSTANCE THIS, AFTER THAT PERMISSION GRANTED INSTANCE.

You need to instance the MagicalCamera Class, like this: The fisrt param is the current Activity, and the second the resize percentage photo, and the third param is the Permission Granted

 MagicalCamera magicalCamera = new MagicalCamera(this,RESIZE_PHOTO_PIXELS_PERCENTAGE, magicalPermissions);
 

Activities Methods

You need to call the methods for take or select pictures in activities that this form:

//take photo
magicalCamera.takePhoto();

//select picture
magicalCamera.selectedPicture("my_header_name");

Fragments Methods

You need to call these methods for take or select pictures in fragments:

//take photo
magicalCamera.takeFragmentPhoto(FragmentSample.this);
 
 //select picture
magicalCamera.selectedFragmentPicture(FragmentSample.this, "My Header Example");

As you can see MagicalCamera is working together MagicalPermissions so you don't need to pass a `Runnable` the camera or photo selection will be triggered once permissions are solved.

Override the event onActivityResult

Remember, you need to override the method onActivityResult in your activity or fragment like this

 @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        //CALL THIS METHOD EVER
        magicalCamera.resultPhoto(requestCode, resultCode, data);
        
        //this is for rotate picture in this method
        //magicalCamera.resultPhoto(requestCode, resultCode, data, MagicalCamera.ORIENTATION_ROTATE_180);
        
        //with this form you obtain the bitmap (in this example set this bitmap in image view)
        imageView.setImageBitmap(magicalCamera.getPhoto());
        
        //if you need save your bitmap in device use this method and return the path if you need this
        //You need to send, the bitmap picture, the photo name, the directory name, the picture type, and autoincrement photo name if           //you need this send true, else you have the posibility or realize your standard name for your pictures.
        String path = magicalCamera.savePhotoInMemoryDevice(magicalCamera.getPhoto(),"myPhotoName","myDirectoryName", MagicalCamera.JPEG, true);

       if(path != null){
           Toast.makeText(MainActivity.this, "The photo is save in device, please check this path: " + path, Toast.LENGTH_SHORT).show();
       }else{
           Toast.makeText(MainActivity.this, "Sorry your photo dont write in devide, please contact with fabian7593@gmail and say this error", Toast.LENGTH_SHORT).show();
       }
    }

Get Uri path

You only could use

magicalCamera.getRealPath()

Save Photo in Memory Devices

This method save your bitmap in internal memory device or if the internal memory is full this library save in sdcard (if you have anything) This method have a lot of params that you can need to use the library:

  • Bitmap: This is the bitmap that you need to save in memory device.
  • PhotoName: The name of the photo
  • DirectoryName: The name of directory that you need to save the image
  • Format: the format of the photo, maybe png, jpeg or webp. Depends of that you need.
  • AutoIncrementNameByDate: This variable save the photo with the photo name and the current date and hour. (Only if is true).

For example: myTestMagicalCameraPhoto_20160520131344 -> This is the year 2016, month 5, day 20, hour 13, minute 13 and second 44.

The method:

 public String savePhotoInMemoryDevice(Bitmap bitmap, String photoName, String directoryName,
 Bitmap.CompressFormat format, boolean autoIncrementNameByDate)

Example:

 String path = magicalCamera.savePhotoInMemoryDevice(magicalCamera.getPhoto(), "myTestPhotoName", MagicalCamera.JPEG, true);

Types of Formats for save photos

You have any type of formats for save the pictures and the bitmaps. You can use, the static variables of the library MagicalCamera.

 Bitmap.CompressFormat jpeg = MagicalCamera.JPEG;
 Bitmap.CompressFormat png = MagicalCamera.PNG;
 Bitmap.CompressFormat webp = MagicalCamera.WEBP;

Resize photo in real time

You can resize the photo in any moment with this:

   magicalCamera.setResizePhoto(newResizeInteger);

Conversion Methods

The library have any methods to convert the bitmap in other formats that you need. All of this methods are public statics, I mean that you dont have to instance the library for usage this. You need to call the class * ConvertSimpleImage * And the respective params.

  • bitmapToBytes: Convert the bitmap to array bytes, only need the bitmap param and the compress format, return array bytes.
  • bytesToBitmap: Convert the array bytes to bitmap, only need the array bytes in param, return bitmap.
  • bytesToStringBase64: Convert the array bytes to String base 64, only need the array bytes format in param, return String.
  • stringBase64ToBytes: Convert string to array bytes, only need the String in param, return array bytes.

Example:

  //convert the bitmap to bytes
  byte[] bytesArray =  ConvertSimpleImage.bitmapToBytes(magicalCamera.getPhoto(), MagicalCamera.PNG);
  
   //convert the bytes to string 64, with this form is easly to send by web service or store data in DB
   String imageBase64 = ConvertSimpleImage.bytesToStringBase64(bytesArray);

   //if you need to revert the process
   byte[] anotherArrayBytes = ConvertSimpleImage.stringBase64ToBytes(imageBase64);

  //again deserialize the image
  Bitmap myImageAgain = ConvertSimpleImage.bytesToBitmap(anotherArrayBytes);

Rotate picture

You have the posibility of rotate picture because some devices have the camera in landscape, and the picture is shown upside down. If you need to rotate image use in event onActivityResult the method with the last param:

  magicalCamera.resultPhoto(requestCode, resultCode, data, MagicalCamera.ORIENTATION_ROTATE_180);

or if you rotate manually in another part of code use method:

//rotate any image
Bitmap myImage = magicalCamera.rotatePicture(magicalCamera.getPhoto(),  MagicalCamera.ORIENTATION_ROTATE_90);

//rotate the getPhoto in magicalCamera Object
Bitmap myImage = magicalCamera.rotatePicture(MagicalCamera.ORIENTATION_ROTATE_NORMAL);

You have this posibillities of rotate image:

MagicalCamera.ORIENTATION_ROTATE_NORMAL
MagicalCamera.ORIENTATION_ROTATE_90
MagicalCamera.ORIENTATION_ROTATE_180
MagicalCamera.ORIENTATION_ROTATE_270

Facial Recognition:

This is a method to return your bitmap (magicalCamera.getPhoto()) like another bitmap with a square draws arround the face of the photo, with the posibillity of modify the color and the stroke of the square. And this is not all, you have the posibility of call the List of the photo with facial recognitions, for save data of all faces, for example the distance between eyes, the nose position and mounth position, all of this is important information for facials recognitions.

You need to write for example:

if(magicalCamera != null){
    if(magicalCamera.getPhoto() != null){
         //this comment line is the strok 5 and color red for default
         //imageView.setImageBitmap(magicalCamera.faceDetector());
         //you can the posibility of send the square color and the respective stroke
         imageView.setImageBitmap(magicalCamera.faceDetector(50, Color.GREEN));

         List<Landmark> listMark = magicalCamera.getListLandMarkPhoto();
     }else{
         Toast.makeText(MainActivity.this,
                 "Your image is null, please select or take one",
                 Toast.LENGTH_SHORT).show();
     }
 }else{
     Toast.makeText(MainActivity.this,
             "Please initialized magical camera, maybe in static context for use in all activity",
             Toast.LENGTH_SHORT).show();
 }

The photo and bitmap converted is like to:

alt tag

Private information Photo:

This method show you the private information photo if the photo is saved in device or not... For view all information the device need to activate GPS locations (and maybe internet), else not show all information :(.

You need to write this code for example:

 //verify if the bitmap of image have data
 if(magicalCamera.getPhoto()!=null) {
   //verify if this photo is save in device, and if has private information to show and return true if have information, or false is not
   if(magicalCamera.initImageInformation()) {

         StringBuilder builderInformation = new StringBuilder();

         if (notNullNotFill(magicalCamera.getPrivateInformation().getLatitude() + ""))
             builderInformation.append("Latitude: " + magicalCamera.getPrivateInformation().getLatitude() + "\n");

         if (notNullNotFill(magicalCamera.getPrivateInformation().getLatitudeReference()))
             builderInformation.append("Latitude Reference: " + magicalCamera.getPrivateInformation().getLatitudeReference() + "\n");

         if (notNullNotFill(magicalCamera.getPrivateInformation().getLongitude() + ""))
             builderInformation.append("Longitude: " + magicalCamera.getPrivateInformation().getLongitude() + "\n");

         if (notNullNotFill(magicalCamera.getPrivateInformation().getLongitudeReference()))
             builderInformation.append("Longitude Reference: " + magicalCamera.getPrivateInformation().getLongitudeReference() + "\n");

         if (notNullNotFill(magicalCamera.getPrivateInformation().getDateTimeTakePhoto()))
             builderInformation.append("Date time to photo: " + magicalCamera.getPrivateInformation().getDateTimeTakePhoto() + "\n");

         if (notNullNotFill(magicalCamera.getPrivateInformation().getDateStamp()))
             builderInformation.append("Date stamp to photo: " + magicalCamera.getPrivateInformation().getDateStamp() + "\n");

         if (notNullNotFill(magicalCamera.getPrivateInformation().getIso()))
             builderInformation.append("ISO: " + magicalCamera.getPrivateInformation().getIso() + "\n");

         if (notNullNotFill(magicalCamera.getPrivateInformation().getOrientation()))
             builderInformation.append("Orientation photo: " + magicalCamera.getPrivateInformation().getOrientation() + "\n");

         if (notNullNotFill(magicalCamera.getPrivateInformation().getImageLength()))
             builderInformation.append("Image lenght: " + magicalCamera.getPrivateInformation().getImageLength() + "\n");

         if (notNullNotFill(magicalCamera.getPrivateInformation().getImageWidth()))
             builderInformation.append("Image Width: " + magicalCamera.getPrivateInformation().getImageWidth() + "\n");

         if (notNullNotFill(magicalCamera.getPrivateInformation().getModelDevice()))
             builderInformation.append("Model Device: " + magicalCamera.getPrivateInformation().getModelDevice() + "\n");

         if (notNullNotFill(magicalCamera.getPrivateInformation().getMakeCompany()))
             builderInformation.append("Make company: " + magicalCamera.getPrivateInformation().getMakeCompany() + "\n");

         new MaterialDialog.Builder(MainActivity.this)
                 .title("See photo information")
                 .content(builderInformation.toString())
                 .positiveText("ok")
                 .show();
   }else{
   Toast.makeText(MainActivity.this,
           "This photo donte have ifnormation, remember, for obtain the info you need to save the picture in device before",
           Toast.LENGTH_SHORT).show();
   }
 }else{
   Toast.makeText(MainActivity.this,
           "You dont have data to show because the photo is null (your photo isn't in memory device)",
           Toast.LENGTH_SHORT).show();
 }
 
 
 
 and the method that I use in the example is for validate not null or empty
    private boolean notNullNotFill(String validate){
        if(validate != null){
            if(!validate.trim().equals("")){
                return true;
            }else{
                return false;
            }
        }else{
            return false;
        }
    }

See the example of this infomartion return:

alt tag




Footer Document

Internal documentation

All the code has a internal documentation for more explanation of this example.



Preview of Example


alt tag



Application that use MagicalCamera

UTNCources
ExampleMagicalCamera

Feel free to contact me to add yours apps to this list.



Suggestions

MagicalCamera was created to make Android Devoloper's life easy. If you have any feedback please let us know in the issues by creating an issue with this format:

  • Write what your feedback is about and add the next "tag" including the square brackets [FEEDBACK]

Suggestions about how to improve the library or new features are welcome. Thanks for choosing us.

Credits and Contributors

Author

Fabián Rosales - Frosquivel Developer :

A magical camera author, I do the take camera, select photo, rotate picture, convert bitmap, facial recognition, save picture, get information and others...

alt tag alt tag alt tag alt tag


Contributors

Erick Navarro

MagicalCamera Contributor (Cutiko) Erick Add a best usage of google play library, and he develop the better usage of permissions, and an excellent code refactor for permission class and other components.

Arthur Zettler

MagicalCamera Contributor (arthursz) Arthur create the return path of the image saved like a String.



Contributors are welcome

The goal for MagicalCamera is to allow Android Developers care about what is important, feautures not getting worry about something that should be trivial such as taking a picture. We look forward to make this a great library to make image capture process simple and painless. There are amny features and other issues waiting. If you would like to contribute please reach to us, or maybe be bold! Getting a surprise pull request is very gratifying.



Video

You can see the video explication here (in spanish) This video is for MagicalCamera version 1.0

https://www.youtube.com/watch?v=U-JxaFZDSn4




License

Copyright 2016 Fabian Rosales

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Comments
  • Photos are always in landscape

    Photos are always in landscape

    Greetings

    I have being using this since a while now, and it is great. However, today I notice, always photos are stored in landscape orientation, what if the user take a photo in portrait orientation.

    I thought this could be just my phone, so I try it with another, and same problem in both (Samsung galaxy note neo 3 and Sony xperia).

    opened by cutiko 16
  • NullPointerException name

    NullPointerException name

    java.lang.RuntimeException: Unable to resume activity {com.frosquivel.examplemagicalcamera/com.frosquivel.examplemagicalcamera.MainActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=null} to activity {com.frosquivel.examplemagicalcamera/com.frosquivel.examplemagicalcamera.MainActivity}: java.lang.NullPointerException: name == null at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2790) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2819) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254) at android.app.ActivityThread.access$800(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5052) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=null} to activity {com.frosquivel.examplemagicalcamera/com.frosquivel.examplemagicalcamera.MainActivity}: java.lang.NullPointerException: name == null at android.app.ActivityThread.deliverResults(ActivityThread.java:3367) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2777) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2819)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254)  at android.app.ActivityThread.access$800(ActivityThread.java:141)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:136)  at android.app.ActivityThread.main(ActivityThread.java:5052)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)  at dalvik.system.NativeStart.main(Native Method)  Caused by: java.lang.NullPointerException: name == null at java.io.File.<init>(File.java:150) at java.io.File.<init>(File.java:124) at com.frosquivel.magicalcamera.MagicalCamera.getPhotoFileUri(MagicalCamera.java:349) at com.frosquivel.magicalcamera.MagicalCamera.onTakePhotoResult(MagicalCamera.java:229) at com.frosquivel.magicalcamera.MagicalCamera.resultPhoto(MagicalCamera.java:191) at com.frosquivel.examplemagicalcamera.MainActivity.onActivityResult(MainActivity.java:81) at android.app.Activity.dispatchActivityResult(Activity.java:5437) at android.app.ActivityThread.deliverResults(ActivityThread.java:3363) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2777) 

    opened by avew 11
  • Crashing on takePhoto

    Crashing on takePhoto

    Device - Xiomi A1 OS - 8.0.0

    App is crashing when we take photo and magicalCamera.resultPhoto(requestCode, resultCode, data); is crashing in onActivityResult.

    I have also tested your application on Google Play, that is also crashing.

    Logs: Process: com.test.imagesearch, PID: 24454 java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=null} to activity {com.test.imagesearch/com.test.imagesearch.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:4348) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4391) at android.app.ActivityThread.-wrap19(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:172) at android.app.ActivityThread.main(ActivityThread.java:6637) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference at com.frosquivel.magicalcamera.Utilities.PictureUtils.resizePhoto(PictureUtils.java:43) at com.frosquivel.magicalcamera.Functionallities.ActionPicture.onTakePhotoResult(ActionPicture.java:184) at com.frosquivel.magicalcamera.Functionallities.ActionPicture.resultPhoto(ActionPicture.java:203) at com.frosquivel.magicalcamera.MagicalCamera.resultPhoto(MagicalCamera.java:206) at com.test.imagesearch.MainActivity.onActivityResult(MainActivity.java:123) at android.app.Activity.dispatchActivityResult(Activity.java:7235) at android.app.ActivityThread.deliverResults(ActivityThread.java:4344)

    bug 
    opened by vishalgupta1987 10
  • NullPointerException - Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference

    NullPointerException - Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference

    Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference at com.frosquivel.magicalcamera.Utilities.PictureUtils.resizePhoto(PictureUtils.java:43) at com.frosquivel.magicalcamera.Functionallities.ActionPicture.onTakePhotoResult(ActionPicture.java:184) at com.frosquivel.magicalcamera.Functionallities.ActionPicture.resultPhoto(ActionPicture.java:203) at com.frosquivel.magicalcamera.MagicalCamera.resultPhoto(MagicalCamera.java:206) at com.example.luis.myapplication.views.SubsectorActivity.onActivityResult(SubsectorActivity.java:1451) at android.app.Activity.dispatchActivityResult(Activity.java:6442) at android.app.ActivityThread.deliverResults(ActivityThread.java:3716) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3763) at android.app.ActivityThread.-wrap16(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1403) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5443) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

    opened by sebamena 6
  • Problem with Android >= 24

    Problem with Android >= 24

    Hi, I think this lib is not supporting Android 24 properly. I am getting this error:

    android.os.FileUriExposedException: file:///storage/emulated/0/... exposed

    Reference: http://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed

    Regards,

    opened by jaesga 5
  • Rotate picture

    Rotate picture

    Yes I can rotate the picture. But according to what? When I take a picture with the phone vertically the photo is turned 90 ° in the ImageView, have you planned something on this subject?

    opened by Simston 4
  • FileUriExposedException in Fragment

    FileUriExposedException in Fragment

    Hi, i am get this error : android.os.FileUriExposedException: file://com.frosquivel.magicalcamera.Provider.PhotoProvider/storage/emulated/0/Android/data/com.example.smr.scc1/files/Pictures/MagicalCamera/MagicalCamera exposed beyond app through ClipData.Item.getUri()

    I am using 'com.frosquivel:magicalcamera:6.0.0' I really apreciate your help...

    opened by camposvo 3
  • Can't take a picture on Android 6.0 or higher

    Can't take a picture on Android 6.0 or higher

    I can't open the camera and take a pic using magicalcamera. The code magicalCamera.takePhoto(); doesn't work on the following devices:

    • ZTE BLADE A510. Android 6.0;
    • LG X power. Android 6.0;
    • Xiaomi Redmi 4X. Android 7.0.

    Saying "the code doesn't work" I mean it literally doesn't do anything. No crashes, no errors, no any reaction.

    BUT it works perfectly on Oysters Pacific E. Android 6.0...I can't find the difference...

    I'm using 5.0.2 version

    opened by geeflizz 3
  • NullPointerException 'int android.graphics.Bitmap.getWidth()' on a null object reference

    NullPointerException 'int android.graphics.Bitmap.getWidth()' on a null object reference

    Hi. I get the following crash when taking pictures. But doesn't happen every time. java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:3720) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3763) at android.app.ActivityThread.-wrap16(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1403) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5443) 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) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference at com.frosquivel.magicalcamera.Utilities.PictureUtils.resizePhoto(PictureUtils.java:43) at com.frosquivel.magicalcamera.Functionallities.ActionPicture.onTakePhotoResult(ActionPicture.java:221) at com.frosquivel.magicalcamera.Functionallities.ActionPicture.resultPhoto(ActionPicture.java:240) at com.frosquivel.magicalcamera.MagicalCamera.resultPhoto(MagicalCamera.java:163) at ar.com.nabla.sistemalecturas.fragment.UnidadFragment.onActivityResult(UnidadFragment.java:1167) at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:164) at ar.com.nabla.sistemalecturas.activity.UnidadActivity.onActivityResult(UnidadActivity.java:162) at android.app.Activity.dispatchActivityResult(Activity.java:6442) at android.app.ActivityThread.deliverResults(ActivityThread.java:3716) ... 9 more

    opened by jeronimosodero 3
  • NoClassDefFoundError when using imageView.setImageBitmap(magicalCamera.faceDetector())

    NoClassDefFoundError when using imageView.setImageBitmap(magicalCamera.faceDetector())

    FATAL EXCEPTION: main
                                                                       Process: com.facedetection, PID: 25183
                                                                       java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/vision/face/FaceDetector$Builder;
                                                                           at com.frosquivel.magicalcamera.Functionallities.FaceRecognition.faceDetection(FaceRecognition.java:68)
                                                                           at com.frosquivel.magicalcamera.Functionallities.FaceRecognition.faceDetector(FaceRecognition.java:51)
                                                                           at com.frosquivel.magicalcamera.MagicalCamera.faceDetector(MagicalCamera.java:109)
                                                                           at com.facedetection.MagicBaby.onActivityResult(MagicBaby.java:73)
                                                                           at android.app.Activity.dispatchActivityResult(Activity.java:7137)
                                                                           at android.app.ActivityThread.deliverResults(ActivityThread.java:4921)
                                                                           at android.app.ActivityThread.handleSendResult(ActivityThread.java:4968)
                                                                           at android.app.ActivityThread.access$1600(ActivityThread.java:222)
                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1849)
                                                                           at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                           at android.os.Looper.loop(Looper.java:158)
                                                                           at android.app.ActivityThread.main(ActivityThread.java:7229)
                                                                           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)
                                                                        Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.vision.face.FaceDetector$Builder" on path: DexPathList[[zip file "/data/app/com.facedetection-1/base.apk"],nativeLibraryDirectories=[/data/app/com.facedetection-1/lib/arm64, /vendor/lib64, /system/lib64]]
                                                                           at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                                           at com.frosquivel.magicalcamera.Functionallities.FaceRecognition.faceDetection(FaceRecognition.java:68) 
                                                                           at com.frosquivel.magicalcamera.Functionallities.FaceRecognition.faceDetector(FaceRecognition.java:51) 
                                                                           at com.frosquivel.magicalcamera.MagicalCamera.faceDetector(MagicalCamera.java:109) 
                                                                           at com.facedetection.MagicBaby.onActivityResult(MagicBaby.java:73) 
                                                                           at android.app.Activity.dispatchActivityResult(Activity.java:7137) 
                                                                           at android.app.ActivityThread.deliverResults(ActivityThread.java:4921) 
                                                                           at android.app.ActivityThread.handleSendResult(ActivityThread.java:4968) 
                                                                           at android.app.ActivityThread.access$1600(ActivityThread.java:222) 
                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1849) 
                                                                           at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                           at android.os.Looper.loop(Looper.java:158) 
                                                                           at android.app.ActivityThread.main(ActivityThread.java:7229) 
                                                                           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) 
                                                                       	Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.vision.face.FaceDetector$Builder
                                                                           at java.lang.Class.classForName(Native Method)
                                                                           at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                                           at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                                           		... 16 more
                                                                        Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
    

    I have all permissions in manifest and requested all permissions at runtime.

    opened by riadrifai22 3
  • Permissions in fragments [REQUEST]

    Permissions in fragments [REQUEST]

    Greetings

    Usually fragments will modularized blocks of logic. Taking a picture is a block of logic by itself. If it is, gallery or camera, getting the result, updating the UI, saving the photo locally and cloud, etc.

    Dialog for permissions using the library method are displaying if are requested from a fragment:

    permissionGranted.checkCameraPermission();
    permissionGranted.checkReadExternalPermission();
    permissionGranted.checkWriteExternalPermission();
    

    The problem is onRequestPermissionsResult is never called in the fragment, but it does in the Activity.

    Initially I thought this could be due some sort of device error, so try with others, including emulator and the behaviour was the same. This seems to be not mentioned in the official docs but I found a clue searching in StackOverflow.

    It seems that asking permissions from a fragment is different than from an Activity.

    Permissions feature is great, thanks for it, but if you could add a fragment version for the permissions it would help us a lot to write more robust code. Thanks.

    opened by cutiko 3
  • java.lang.NullPointerException in Fragment

    java.lang.NullPointerException in Fragment

    Hi guys! Tell me how to catch the result of a photo in a Fragment? I have a parent activity for navigation drawer menu and several fragments, but a photo is required in one fragment

    opened by saserg 0
  • INSTALL_FAILED_CONFLICTING_PROVIDER

    INSTALL_FAILED_CONFLICTING_PROVIDER

    i haven't encountered the error when i am using the library in two projects. I can only install either one application on testing devices and got this error when i try to install second application to same testing device. Both applications install successfully if i remove this library on either one project. How do i solve this?

    opened by allanckto 1
  • Permission Problem After Marshmallow

    Permission Problem After Marshmallow

    Hello, Thanks for great library. I got a problem about permissions.. If user has no permissions on Camera and Storage, MagicalCamera itself cannot handle it and "return mapPermissions?.get(permission)!!" returns NullPointerException. (Tried on both Java and Kotlin)

    
     private fun isActivePermission(permission: String): Boolean {
            // This map is return in method onRequestPermissionsResult for view what permissions are actives
            if (android.os.Build.VERSION.SDK_INT >= 23) {
                if (mapPermissions != null) {
                    if (mapPermissions!!.size > 0) {
                        // Obtain the code of camera permissions
                         return mapPermissions?.get(permission)!!
                    } else {
                        return true
                    }
                } else {
                    return true
                }
            } else {
                return true
            }
        }
    

    I could not solve the problem, please help me. Thank you

    bug question 
    opened by WrathChaos 3
  • Duplicate pictures

    Duplicate pictures

    Hi. All works when I take a picture and I save it in my custom directory. The problem is that it also save it in DCIM directory with full quality. I'm testing in Android 7.0. Thanks.

    bug 
    opened by jeronimosodero 1
Owner
Fabian Rosales (Frosquivel Developer)
Mobile and Web API Developer. ♚ Family, Love, Freedom, Music, Software Programming, Arduino, Design, Photography♚
Fabian Rosales (Frosquivel Developer)
Camera Folder: "Take a Photo from Camera" everywhere where you can open a photo file

When "Camera Folder" is installed many Android-Apps that can open jpg files can also take a photo from camera.

k3b 18 Dec 20, 2022
Android camera and serial communication utility that interacts with another device via a USB connection.

PVIT-Payload-Source Android camera and serial communication utility that interacts with another device via a USB connection. PVIT = Palos Verdes Insti

Zeroz & Onez 1 Nov 10, 2021
NguyenThienAn06105 - This repository consist of the code to read camera data on ESP8266 and a simple Android application to visualize the …

MLX90640-HeatCamera This repository consist of the code to read camera data on ESP8266 and a simple Android application to visualize the result. There

Christian Hein 0 Jan 1, 2022
Bootcamp - Digital Innovation One e NTT Data - Aula de Recursos Nativos do Android

Recursos-Nativos-Android -Foto e Camera Bootcamp - Digital Innovation One e NTT Data - Aula de Recursos Nativos do Android Tutorial de uso da bibliote

Anne Nicolle Zimmermann 0 Jan 3, 2022
📸 A library that allows you to capture images secretly, in background without alerting users.

HiddenCamera A library that allows you to capture images secretly, in background without alerting users. Gradle Dependency Add the dependency to your

Cotta & Cush Limited 116 Dec 29, 2022
Android library to choose image from gallery or camera with option to compress result image

ImagePicker Android library to choose image from gallery or camera with option to compress result image. Download Add this to your project's build.gra

Mayank Nagwanshi 73 May 20, 2022
Image Picker library for Android

Ronnie-Image-Picker Asks for Camera and storage permission and return uri of the images taken or picked from the gallery. Min Api Level: 16 Build Syst

Ronnie Otieno 33 Nov 19, 2022
A new camera app for GrapheneOS based on the modern CameraX library.

This is the new GrapheneOS Camera app based on Android's modern CameraX library. It's currently in the alpha phase and isn't yet included in GrapheneO

GrapheneOS 513 Jan 1, 2023
Snappy - an android camerax library for taking snapshot fast & simple

Snappy is an android camerax library for taking snapshot fast & simple. Easy to integrate, 100% Kotlin & jetpack compose driven.

Nils Druyen 16 Dec 15, 2022
Quick photo and video camera with a flash, customizable resolution and no ads.

Simple Camera A camera with flash, zoom and no ads. The camera is usable for both photo taking and video recording. You can switch between front and r

Simple Mobile Tools 644 Jan 7, 2023
Android application to preview, record (MediaRecorder), and fetch each image from both front and rear cameras simultaneously

DuoCamera ?? Overview Android application to preview, record (MediaRecorder) and fetch each image from both front and rear cameras simultaneously. The

Igor Lashkov 5 Nov 28, 2022
Powerful custom Android Camera with granular control over the video quality and filesize, restricting recordings to landscape only.

LandscapeVideoCamera Highly flexible Android Camera which offers granular control over the video quality and filesize, while restricting recordings to

Jeroen Mols 1.2k Nov 22, 2022
Measures human heart rate using camera and flash light.

Heart-Rate-Ometer Introduction Measures human heart rate using camera and flash light. How-it-works https://github.com/phishman3579/android-heart-rate

Jan Rabe 81 Jun 29, 2022
It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android.

Shutter-Android It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android. What is Shutter? Shutter is an Androi

Levi Bostian 56 Oct 3, 2022
It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android.

Shutter-Android It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android. What is Shutter? Shutter is an Androi

Levi Bostian 56 Oct 3, 2022
Astronomy Picture of the Day Nasa(APOD) media listing and show picture details.

Astronomy Picture of the Day Nasa(APOD) media listing and show picture details. Built to learn and use of Latest Android development libs using Coroutines, Flow, Dagger-Hilt, Architecture Components, MVVM, Room, Retrofit, Material Guideline)

pRaNaY 5 Oct 18, 2022
An easy-to-use Android library that will help you to take screenshots of specif views of your app and save them to external storage (Including API 29 Q+ with Scope Storage)

???? English | ???? Português (pt-br) ???? English: An easy to use Library that will help you to take screenshots ?? of the views in your app Step 1.

Thyago Neves Silvestre 2 Dec 25, 2021
💰 A library to dynamically format your EditTexts to take currency inputs

CurrencyEditText A library to dynamically format your EditTexts to take currency inputs. Gradle Dependency Add the dependency to your app's build.grad

Cotta & Cush Limited 115 Dec 28, 2022
🌠 Transform into a different view or activity using morphing animations.

TransformationLayout ?? Transform into a different view or activity using morphing animations. Using Transformation motions of new material version. D

Jaewoong Eum 2k Jan 3, 2023