• 12
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

This question already has answers here:

For android 8.0 or above you have to add create file provider to access photos. to add file provider

add following tag in your manifest file under application tag.

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

</provider>

Create provider_paths.xml in xml folder

<?xml version="1.0" encoding="utf-8"?>
<paths>
    <external-path
        name="external_files"
        path="." />
</paths>

Intent to capture image

Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                    // Create the File where the photo should go
                    File photoFile = null;
                    try {
                        photoFile = createImageFile();
                    } catch (IOException ex) {
                        // Error occurred while creating the File

                    }
                    // Continue only if the File was successfully created
                    if (photoFile != null) {
                        if ((Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT)) {
                            photoURI = FileProvider.getUriForFile(getContext(),
                                    "com.example.provider",
                                    photoFile);
                            //FAApplication.setPhotoUri(photoURI);
                        } else {
                            photoURI = Uri.fromFile(photoFile);
                        }

                        takePicture.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
                        startActivityForResult(takePicture, 101);

And in onActivity result

if (requestCode == 101) {
                    Uri contentUri = FileProvider.getUriForFile(getContext(), "com.example.provider", new File(mCurrentPhotoPath)); //You wll get the proper image uri here.
                }

createImageFile()

private File createImageFile() throws IOException {
        // Create an image file name
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        String imageFileName = "JPEG_" + timeStamp + "_";
        File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);


        /*File file = new File(getContext().getExternalFilesDir(Environment.DIRECTORY_PICTURES)
                + File.separator
                + imageFileName);
        if (file.getParentFile().exists() || file.getParentFile().mkdirs()) {
            mCurrentPhotoPath = file.getAbsolutePath();
        }*/


        File file = File.createTempFile(
                imageFileName,   //prefix
                ".jpg",          //suffix
                storageDir       //directory
        );

        // Save a file: path for use with ACTION_VIEW intents

        return file;
    }
  • 1
Reply Report