Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6773701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:41:57+00:00 2026-05-26T15:41:57+00:00

I am going to implement camera feature for my android app.for this, I searched

  • 0

I am going to implement camera feature for my android app.for this, I searched a lot on internet and found 2 way to implement camera feature

  1. design your own camera class using

    android.view.SurfaceHolder and
    android.view.SurfaceView

but this approach does look good to me as in this i have to take care of many things which will make my code complex.

  2.   I can use intent to call device camera. now again in this , i have 2 option

            i ) using MediaStore.EXTRA_OUTPUT and not using MediaStore.EXTRA_OUTPUT

if i dont use MediaStore.EXTRA_OUTPUT I get a thumbnail which is not my actual requirement. i need image larger than this so if I scale this thumbnail, i find low quality image.

if i use MediaStore.EXTRA_OUTPUT I dint get any image on some device like samsung as in

onActivityResult(int requestCode, int resultCode, Intent intent)

I find intent is null . after searching a lot on internet, i found that this is device specific issue. i have Samsung Galaxy with me. and on this i am facing this issue.

i dont want my code to be a device specific code. so can any one tell me how to make my code generic. for your analysis, i am using following code

@Override
public void onCreate(Bundle savedInstanceState) {

    try {

        super.onCreate(savedInstanceState);         
                File root = new File(Environment
                        .getExternalStorageDirectory()
                        + File.separator + "myDir" + File.separator)
                if(!root.exists()){
                    root.mkdirs();
                }
                sdImageMainDirectory = new File(root, "myPicName");
            startCameraActivity();
        }
    catch (Exception e) {
        finish();
        Toast.makeText(this, "Error occured. Please try again later.",
                Toast.LENGTH_SHORT).show();
    }
}
Uri outputFileUri;
protected void startCameraActivity() {

    outputFileUri = Uri.fromFile(sdImageMainDirectory);
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
    startActivityForResult(intent, 0);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    switch (resultCode) {
    case 0:
        finish();
        break;

    case -1:

        try {
            if(intent != null)
            StoreImage(this, Uri.parse(intent.toURI()),
                    sdImageMainDirectory);

        } catch (Exception e) {
            e.printStackTrace();
        }


        Intent i = new Intent(this,Home.class);
        i.putExtra("url", outputFileUri);
        startActivity(i);
        finish();
    }

}
public static void StoreImage(Context mContext, Uri imageLoc, File imageDir) {
    Bitmap bm = null;
    try {
        bm = Media.getBitmap(mContext.getContentResolver(), imageLoc);
        FileOutputStream out = new FileOutputStream(imageDir);
        bm.compress(Bitmap.CompressFormat.JPEG, 100, out);
        bm.recycle();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:41:57+00:00Added an answer on May 26, 2026 at 3:41 pm

    Please check this link: Capture image using Intent

    This code works fine in all the Samsung devices I have used (like Galaxy S, Galaxy Tab, Galaxy Pro).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm going to implement my strings with internationalization in my Android app. I have
What's the best way going forward to implement Wake on LAN using C#? The
I'm going to implement JSON-RPC web service. I need specifications for this. So far
We are going to implement a fairly complex new service in an asynchronous way,
I need your advice deciding on a new project architecture I'm going to implement.
When i am going to implement Authorize.net payment gateway. However, I got this error:
I'm going to implement a view similar to the original photo app in iOS.
I`m going to implement a login feature to a website that I`m building ...
I am going to implement an application that is gathering data from Android device.
I am trying to achieve this in an android app layout. So far I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.