三星 Galaxy S3 4.1.1 版中的相机强制关闭问题 [英] Camera Force Closing issue in Samsung Galaxy S3 version 4.1.1

查看:25
本文介绍了三星 Galaxy S3 4.1.1 版中的相机强制关闭问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想捕获图像并将其保存在我的应用程序"之一的图像视图中.我已经知道如何实现它,并且在除三星 Galaxy S3 之外的所有设备上都能正常工作.

I want to capture image and save it in Image view in one of My Application. I already have an idea how to implement it and also Works fine in all device Except Samsung Galaxy S3.

我想要什么:避免三星 Galaxy S3 中出现的强制关闭问题,可能适用于我尚未测试的所有其他设备.

What I Want: Avoid the Force Closing Issue Coming in Samsung Galaxy S3 and probably for all other Device which i have not yet tested.

我做了什么:我已经完成了下面的代码来实现我的目标.

What I have Done: I have Done the Below Code to achieve my goal.

BuildInukshk_4 活动:

BuildInukshk_4 Activity :

package com.inukshk.CreateInukshk;

import java.util.Calendar;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.StatFs;
import android.provider.MediaStore;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.inukshk.R;
import com.inukshk.constant.ImageCurve;

public class BuildInukshk_4 extends Activity implements OnClickListener,
        OnDismissListener {

    String TAG = "BuildInukshk_4";
    Button btn_back, btn_upload_picture;
    TextView txt_next;

    public static Activity BuildInukshk_4Activity;

    // Upload Camera
    public static String media = null;
    public static String media_thumb = null;
    public static String media_type = null;
    AlertDialog dialog;
    String _path, Place = "";
    ImageView imageView;
    boolean flag = true;
    Uri uriVideo = null, mCapturedImageURI = null;
    private static final int SELECT_PICTURE = 1;
    private String selectedImagePath = "";
    Uri selectedImageUri = null;
    private String filemanagerstring;
    Bitmap mBitmap;

    // From Transperant
    ContentResolver crThumb;
    private static final int CAMERA_PIC_REQUEST = 2500, VIDEO_REQUEST_CODE = 3;
    final static int REQUEST_VIDEO_CAPTURED = 2;
    BitmapFactory.Options options;
    String fileName;
    long id, imageid;
    Cursor cursor, cursorimage, thumbCursor;

    private String selectedthumbpath = "";
    boolean finish = false;
    // ADDED12324
    // private String filemanagerstring;

    Bitmap curThumb = null, curThumb1 = null;
    String[] thumbColumns = { MediaStore.Video.Thumbnails.DATA,
            MediaStore.Video.Thumbnails.VIDEO_ID };

    String[] mediaColumns = { MediaStore.Video.Media._ID,
            MediaStore.Video.Media.DATA };

    String[] imageColumns = { MediaStore.Images.Media._ID,
            MediaStore.Images.Media.DATA };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.buildinukshk_4);

        BuildInukshk_4Activity = this;
        btn_back = (Button) findViewById(R.id.btn_back);
        btn_back.setOnClickListener(this);

        btn_upload_picture = (Button) findViewById(R.id.btn_upload_picture);
        btn_upload_picture.setOnClickListener(this);

        txt_next = (TextView) findViewById(R.id.txt_next);
        txt_next.setOnClickListener(this);

        imageView = (ImageView) findViewById(R.id.img_upload_pic);
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub

        if (v == txt_next) {
            if (selectedImagePath.equals("")) {
                Toast.makeText(BuildInukshk_4.this,
                        "Please Upload Picture First", 3).show();
            } else {
                startActivity(new Intent(BuildInukshk_4.this,
                        BuildInukshk_5.class));
            }

            // this.finish();
        } else if (v == btn_back) {
            // startActivity(new Intent(BuildInukshk_4.this,
            // BuildInukshk_3.class));
            this.finish();
        } else if (v == btn_upload_picture) {
            registerForContextMenu(btn_upload_picture);
            openContextMenu(btn_upload_picture);
        }

    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,
            ContextMenuInfo menuInfo) {
        // TODO Auto-generated method stub
        Log.i(TAG, "Inside onCreateContextMenu");
        super.onCreateContextMenu(menu, v, menuInfo);

        if (v == btn_upload_picture) {
            menu.setHeaderTitle("Upload Media");
            menu.add(0, v.getId(), 0, "Photo");
        }
    }

    @Override
    public boolean onContextItemSelected(MenuItem item) {
        // TODO Auto-generated method stub
        if (item.getTitle() == "Photo") {
            media_type = "image";
            // media_thumb = null;
            /*
             * Intent intent = new Intent(getApplicationContext(),
             * Transperant.class); intent.putExtra("MEDIA_TYPE", media_type);
             * startActivity(intent);
             */

            ImageChooseOptionDialog();
            // ImageChooseOptionDialog();

        }
        return super.onContextItemSelected(item);
    }

    // Transperant Class
    private void ImageChooseOptionDialog() {

        // finish = true;

        Log.i(TAG, "Inside ImageChooseOptionDialog");
        dialog = new AlertDialog.Builder(BuildInukshk_4.this).create();
        dialog.setTitle("Upload Photo");
        dialog.setMessage("Choose your Photo From here.");
        dialog.setOnDismissListener(this);
        dialog.setButton("Camera", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                // dialog.dismiss();
                Log.i(TAG, "Inside ImageChooseOptionDialog inside camera");

                Boolean isSDPresent = android.os.Environment
                        .getExternalStorageState().equals(
                                android.os.Environment.MEDIA_MOUNTED);
                mCapturedImageURI = null;
                if (isSDPresent) {
                    // yes SD-card is present
                    StatFs stat = new StatFs(Environment
                            .getExternalStorageDirectory().getPath());
                    long bytesAvailable = (long) stat.getBlockSize()
                            * (long) stat.getAvailableBlocks();
                    long megAvailable = bytesAvailable / (1024 * 1024);
                    Log.e("", "Available MB : " + megAvailable);
                    if (megAvailable > 2) {
                        Calendar cal = Calendar.getInstance();
                        _path = cal.getTimeInMillis() + ".jpg";

                        String fileName = _path;
                        // File file = new File(_path);
                        // mCapturedImageURI = Uri.fromFile(file);
                        ContentValues values = new ContentValues();
                        values.put(MediaStore.Images.Media.TITLE, fileName);

                        mCapturedImageURI = getContentResolver().insert(
                                MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                                values);

                        Log.d(TAG, "----- path ----- " + _path);

                        Intent intent = new Intent(
                                android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

                        intent.putExtra(MediaStore.EXTRA_OUTPUT,
                                mCapturedImageURI);

                        Log.d(TAG, "----- mCapturedImageURI ******----- "
                                + mCapturedImageURI);
                        startActivityForResult(intent, 1212);

                        flag = false;
                    } else {

                        Toast.makeText(BuildInukshk_4.this,
                                "No Memory Available", 2).show();
                        flag = true;
                    }
                } else {
                    // Sorry
                    // StatFs stat = new StatFs(Environment.getDataDirectory()
                    // .getPath());
                    // long bytesAvailable = (long) stat.getBlockSize()
                    // * (long) stat.getAvailableBlocks();
                    // long megAvailable = bytesAvailable / (1024 * 1024);
                    // Log.e("", "Internal MB : " + megAvailable);
                    // if (megAvailable > 2) {
                    // startActivityForResult(new Intent(Transperant.this,
                    // VideoRecorder.class), REQUEST_VIDEO_CAPTURED);
                    //
                    // flag = false;
                    // } else {
                    Toast.makeText(BuildInukshk_4.this, "No Memory Available",
                            2).show();
                    flag = true;
                    // }
                    // Toast.makeText(Transperant.this, "No External Storage",
                    // 2)
                    // .show();
                }

            }
        });
        dialog.setButton2("Gallery", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                Log.i(TAG, "Inside Gallary");
                Log.i(TAG, "Inside ImageChooseOptionDialog inside camera");
                // dialog.dismiss();
                Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(
                        Intent.createChooser(intent, "Select Picture"),
                        SELECT_PICTURE);
                flag = false;

            }
        });

        dialog.show();

    }

    @Override
    public void onDismiss(DialogInterface dialog) {
        // TODO Auto-generated method stub

    }

    public String getPath(Uri uri) {
        String[] projection = { MediaStore.Images.Media.DATA };
        Cursor cursor = managedQuery(uri, projection, null, null, null);
        if (cursor != null) {
            // HERE YOU WILL GET A NULLPOINTER IF CURSOR IS NULL
            // THIS CAN BE, IF YOU USED OI FILE MANAGER FOR PICKING THE MEDIA
            int column_index = cursor
                    .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            cursor.moveToFirst();
            return cursor.getString(column_index);
        } else
            return null;
    }

    public void onActivityResult(int requestCode, int resultCode,
            final Intent data) {

        crThumb = getContentResolver();
        options = new BitmapFactory.Options();
        options.inSampleSize = 1;
        Log.i(TAG, "Inside onActivityResult");

        if (requestCode == SELECT_PICTURE) {
            if (resultCode == RESULT_OK) {
                Log.i(TAG, "SELECT_PICTURE");
                selectedImageUri = data.getData();
                // filemanagerstring = selectedImageUri.getPath();
                selectedImagePath = getPath(selectedImageUri);
                if (selectedImagePath != null) {
                    BuildInukshk_4.media = selectedImagePath;
                    Log.e("Image path", selectedImagePath);

                    mBitmap = BitmapFactory.decodeFile(media);
                    if (mBitmap != null) {
                        Log.i(TAG, "Inside Set Image");
                        imageView.setImageBitmap(mBitmap);
                    }
                    // selectedthumbpath = null;
                    // Testimage();

                    // // curThumb1 = MediaStore.Images.Thumbnails.getThumbnail(
                    // // crThumb, imageid,
                    // // MediaStore.Video.Thumbnails.MICRO_KIND, options);
                    //
                    // Cursor thumbCursorimage = managedQuery(
                    // MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
                    // imageColumns, MediaStore.Images.Thumbnails.IMAGE_ID
                    // + "=" + imageid, null, null);
                    //
                    // Log.e("Transarerant",
                    // "--- inside do TEst Image cusor 2nd -- "
                    // + thumbCursorimage.getCount());
                    // if (thumbCursorimage.moveToFirst()) {
                    // selectedthumbpath = thumbCursorimage
                    // .getString(thumbCursorimage
                    // .getColumnIndex(MediaStore.Images.Thumbnails.DATA));
                    // // selectedthumbpath = new
                    // Log.e("PathofThumb", selectedthumbpath);
                    // BuildInukshk_4.media_thumb = selectedthumbpath;
                    // }

                }
            }

        } else if (requestCode == VIDEO_REQUEST_CODE) {
        }

        else if (requestCode == REQUEST_VIDEO_CAPTURED) {
        }

        else if (requestCode == 1212) {

            if (resultCode == RESULT_OK) {
                Log.i(TAG, "Inside IF CONDITIONS in Camera");
                Log.i(TAG, "mCptureURI :" + mCapturedImageURI);

                String[] projection = { MediaStore.Images.Media.DATA };
                Cursor cursor = managedQuery(mCapturedImageURI, projection,
                        null, null, null);
                int column_index_data = cursor
                        .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
                cursor.moveToFirst();
                selectedImagePath = cursor.getString(column_index_data);
                Log.e("Image path", selectedImagePath);

                BuildInukshk_4.media = selectedImagePath;

                mBitmap = BitmapFactory.decodeFile(media);
                if (mBitmap != null) {
                    Log.i(TAG, "Inside Set Image");
                    // mBitmap = ImageCurve.GetCurveImage(mBitmap);
                    imageView.setImageBitmap(mBitmap);
                }

                // selectedthumbpath = null;
                // Testimage();

                // curThumb1 =
                // MediaStore.Images.Thumbnails.getThumbnail(crThumb,
                // imageid, MediaStore.Video.Thumbnails.MICRO_KIND,
                // options);
                //
                // Cursor thumbCursorimage = managedQuery(
                // MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
                // imageColumns, MediaStore.Images.Thumbnails.IMAGE_ID
                // + "=" + imageid, null, null);
                //
                // Log.e("Transarerant",
                // "--- inside do TEst Image cusor 2nd -- "
                // + thumbCursorimage.getCount());
                // if (thumbCursorimage.moveToFirst()) {
                // selectedthumbpath = thumbCursorimage
                // .getString(thumbCursorimage
                // .getColumnIndex(MediaStore.Images.Thumbnails.DATA));
                // // selectedthumbpath = new
                // Log.e("PathofThumb", selectedthumbpath);
                // BuildInukshk_4.media_thumb = selectedthumbpath;
            }

        }
    }
}

如果我在这里犯了错误,这也是我的清单文件:

Also Here is my Manifest file if i have done my mistake here:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.inukshk"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <!-- FOR Camera -->
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />

    <!-- Don't require camera, as this requires a rear camera. This allows it to work on the Nexus 7 -->
    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.front"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.autofocus"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.flash"
        android:required="false" />
    <uses-feature android:name="android.hardware.screen.landscape" />
    <uses-feature
        android:name="android.hardware.wifi"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />
    <uses-feature android:name="android.hardware.camera" />

    <application
        android:icon="@drawable/app_icon_final"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar" >
        <uses-library android:name="com.google.android.maps" />

        <activity
            android:name=".SplashScreen"
            android:label="@string/title_activity_main"
            android:screenOrientation="sensorPortait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainActivity"
            android:screenOrientation="sensorPortait" />
        <activity
            android:name=".login.LoginActivity"
            android:screenOrientation="sensorPortait"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name=".WhereAmI.WhereAmI"
            android:screenOrientation="sensorPortait" />
        <activity
            android:name=".WhosNearMe.WhosNearMe"
            android:screenOrientation="sensorPortait" />
        <activity
            android:name=".WhatsNearMe.WhatsNearMe"
            android:screenOrientation="sensorPortait" />
        <activity
            android:name=".CreateInukshk.CreateInukshk"
            android:screenOrientation="sensorPortait"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".CreateInukshk.BuildInukshk_1"
            android:screenOrientation="sensorPortait"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".CreateInukshk.BuildInukshk_2"
            android:screenOrientation="sensorPortait"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".CreateInukshk.BuildInukshk_3"
            android:screenOrientation="sensorPortait"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".CreateInukshk.BuildInukshk_4"
            android:screenOrientation="sensorPortait"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".CreateInukshk.BuildInukshk_5"
            android:screenOrientation="sensorPortait"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".tTab.TabSample"
            android:screenOrientation="sensorPortait"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".register.RegisterActivity"
            android:screenOrientation="sensorPortait"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".Transperant"
            android:screenOrientation="sensorPortait" />
        <activity
            android:name=".HomeActivity"
            android:screenOrientation="sensorPortait" />
        <activity
            android:name=".AfterSplash"
            android:screenOrientation="sensorPortait" />
        <activity
            android:name=".login.ForgotPasswordActivity"
            android:screenOrientation="sensorPortait" />
        <activity
            android:name=".settings.MyProfile"
            android:screenOrientation="sensorPortait"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".settings.MyInterests"
            android:screenOrientation="sensorPortait"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".settings.InukshkSettings"
            android:screenOrientation="sensorPortait" />
        <activity
            android:name=".settings.MyPicture"
            android:screenOrientation="sensorPortait" />
        <activity
            android:name=".settings.MyInukshks"
            android:screenOrientation="sensorPortait" />
        <activity
            android:name=".settings.ChangePassword"
            android:screenOrientation="sensorPortait" />
    </application>

</manifest>

我在许多 SO 链接中搜索过这个问题,但没有找到适合我的任何解决方案.请帮助我摆脱困境.

I have searched for this issue in Many SO link but do not quite get any solution worked for me. Please Help me to get out of this.

我想在此说明一下,我没有用于测试此问题的真实设备.
但是我的客户在真实设备上遇到了这个问题.我制作了一个和 S3 一样的模拟器,它在各种场景下都可以毫无顾虑地工作.
我不知道为什么这只发生在真实设备上.

提前致谢

我已经通过修改以下代码解决了上述问题并将其作为答案.你可以在阅读问题后看看.

EDITED : iI have solved the above issue by modifying the below code and put as an answer. You can have a look after reading the question.

推荐答案

我已经为这个单一问题花费了很多时间,并且通过如下修改代码使代码在大多数设备中都能正常工作:

I have Spent many Hours for this Single Issue and Got the Code Working in Most of the Devices With Modifying the Code as Below :

以后遇到同样问题的人可以试试下面的代码.

Any one having the Same issue in future can try out the Below Code.

在调用图像捕获意图时:

While Calling intent for Image Capture :

String storageState = Environment.getExternalStorageState();

                    if (storageState.equals(Environment.MEDIA_MOUNTED)) {
                        Intent intent = new Intent(
                                MediaStore.ACTION_IMAGE_CAPTURE);

                        String filename = System.currentTimeMillis() + ".jpg";
                        ContentValues values = new ContentValues();
                        values.put(MediaStore.Images.Media.TITLE, filename);
                        mImageCaptureUri = getContentResolver().insert(
                                MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                                values);

                        intent.putExtra(
                                android.provider.MediaStore.EXTRA_OUTPUT,
                                mImageCaptureUri);


                        try {

                            startActivityForResult(intent, PICK_FROM_CAMERA);
                        } catch (ActivityNotFoundException e) {
                            e.printStackTrace();
                        }
                    } else {
                        new AlertDialog.Builder(BuildInukshk_4_Camera.this)
                                .setMessage(
                                        "External Storeage (SD Card) is required.

Current state: "
                                                + storageState)
                                .setCancelable(true).create().show();
                    }

                } else { // pick from file
                    Intent intent = new Intent();

                    intent.setType("image/*");
                    intent.setAction(Intent.ACTION_GET_CONTENT);

                    startActivityForResult(Intent.createChooser(intent,
                            "Complete action using"), PICK_FROM_FILE);
                }

OnActivityResult 方法内部:

Inside OnActivityResult Method :

case PICK_FROM_CAMERA:
                Log.i("TAG", "Inside PICK_FROM_CAMERA");

                // Final Code As Below
                try {
                    Log.i("TAG", "inside Samsung Phones");
                    String[] projection = {
                            MediaStore.Images.Thumbnails._ID, // The columns we want
                            MediaStore.Images.Thumbnails.IMAGE_ID,
                            MediaStore.Images.Thumbnails.KIND,
                            MediaStore.Images.Thumbnails.DATA };
                    String selection = MediaStore.Images.Thumbnails.KIND + "=" + // Select
                                                                                    // only
                                                                                    // mini's
                            MediaStore.Images.Thumbnails.MINI_KIND;

                    String sort = MediaStore.Images.Thumbnails._ID + " DESC";

                    // At the moment, this is a bit of a hack, as I'm returning ALL
                    // images, and just taking the latest one. There is a better way
                    // to
                    // narrow this down I think with a WHERE clause which is
                    // currently
                    // the selection variable
                    Cursor myCursor = this.managedQuery(
                            MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
                            projection, selection, null, sort);

                    long imageId = 0l;
                    long thumbnailImageId = 0l;
                    String thumbnailPath = "";

                    try {
                        myCursor.moveToFirst();
                        imageId = myCursor
                                .getLong(myCursor
                                        .getColumnIndexOrThrow(MediaStore.Images.Thumbnails.IMAGE_ID));
                        thumbnailImageId = myCursor
                                .getLong(myCursor
                                        .getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID));
                        thumbnailPath = myCursor
                                .getString(myCursor
                                        .getColumnIndexOrThrow(MediaStore.Images.Thumbnails.DATA));
                    } finally {
                        // myCursor.close();
                    }

                    // Create new Cursor to obtain the file Path for the large image

                    String[] largeFileProjection = {
                            MediaStore.Images.ImageColumns._ID,
                            MediaStore.Images.ImageColumns.DATA };

                    String largeFileSort = MediaStore.Images.ImageColumns._ID
                            + " DESC";
                    myCursor = this.managedQuery(
                            MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                            largeFileProjection, null, null, largeFileSort);
                    String largeImagePath = "";

                    try {
                        myCursor.moveToFirst();

                        // This will actually give yo uthe file path location of the
                        // image.
                        largeImagePath = myCursor
                                .getString(myCursor
                                        .getColumnIndexOrThrow(MediaStore.Images.ImageColumns.DATA));
                        mImageCaptureUri_samsung = Uri.fromFile(new File(
                                largeImagePath));
                        mImageCaptureUri = null;
                    } finally {
                        // myCursor.close();
                    }

                    // These are the two URI's you'll be interested in. They give
                    // you a
                    // handle to the actual images
                    Uri uriLargeImage = Uri.withAppendedPath(
                            MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                            String.valueOf(imageId));
                    Uri uriThumbnailImage = Uri.withAppendedPath(
                            MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
                            String.valueOf(thumbnailImageId));

                    // I've left out the remaining code, as all I do is assign the
                    // URI's
                    // to my own objects anyways...
                } catch (Exception e) {
                    mImageCaptureUri_samsung = null;
                    Log.i("TAG",
                            "inside catch Samsung Phones exception " + e.toString());

                }

                try {
                    Log.i("TAG",
                            "URI Samsung:" + mImageCaptureUri_samsung.getPath());

                } catch (Exception e) {
                    Log.i("TAG", "Excfeption inside Samsung URI :" + e.toString());
                }

                try {

                    Log.i("TAG", "URI Normal:" + mImageCaptureUri.getPath());
                } catch (Exception e) {
                    Log.i("TAG", "Excfeption inside Normal URI :" + e.toString());
                }



                break;

运行以下代码后,您将获得两个 URI mImageCaptureUri_samsungmImageCaptureUri

After Running Below Code you Will get Two URIs mImageCaptureUri_samsung and mImageCaptureUri

如果您使用简单设备运行应用程序,您将获得 mImageCaptureUri 作为您的路径,如果您使用三星 Galaxy S3 等设备运行,您将在 mImageCaptureUri_samsung 中获得您的 Cpatured Image 路径.

you will get the mImageCaptureUri as your Path if you are running the App with Simple Devices and you will get your Cpatured Image path in mImageCaptureUri_samsung if you are running with Devices Like Samsung Galaxy S3.

您还可以继续编写您的代码.它适用于我测试过的所有设备.

Further you all can go ahead with your Code. it Works For me Very Fine With all the Devices i have tested on.

此外,如果有人对上述代码有疑问,他们可以参考下面的大链接 三星Galaxy S3解决方案

Also if Someone is having Problem with Above Code than they can reference the Below Great Link Solution of Samsung Galaxy S3

希望它会有所帮助.

这篇关于三星 Galaxy S3 4.1.1 版中的相机强制关闭问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆