How to solve the null pointer exception while capturing and saving an image using android emulator?
> I am trying to capture and save the image through the android
> emulator, the image is being captured, but the file is being saved is
> corrupted.
> 
> 
> Looking for help to solve this issue,I am using the following code

 
  

    **public void onCreate**(Bundle savedInstanceState) {
        		super.onCreate(savedInstanceState);
        		setContentView(R.layout.main);
        		**Intent** intent = new **Intent**("android.media.action.IMAGE_CAPTURE");
        		try {
        			fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
        		} catch (IOException e) {
        			// TODO Auto-generated catch block
        			e.printStackTrace();
        		}
        		intent.putExtra(**MediaStore**.EXTRA_OUTPUT, fileUri);
        		startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
        
        	}
        
        	@Override
        	**protected void onActivityResult**(int requestCode, int resultCode, Intent data) {
        		if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
        			if (resultCode == RESULT_OK) {
        				StoreImage(this, data.getData(),
        						mediaFile);
        				 	finish();
        		           
        			} else if (resultCode == RESULT_CANCELED) {
        				// User cancelled the image capture
        			} else {
        				finish();
        				try {
        					
        				} catch (Exception e) {
        					e.printStackTrace();
        				}
        	}
        			
        			
        		}
        		
        	}


How to solve the null pointer exception while capturing and saving an image using android emulator?
===

> I am trying to capture and save the image through the android
> emulator, the image is being captured, but the file is being saved is
> corrupted.
> 
> 
> Looking for help to solve this issue,I am using the following code

 
  

    **public void onCreate**(Bundle savedInstanceState) {
        		super.onCreate(savedInstanceState);
        		setContentView(R.layout.main);
        		**Intent** intent = new **Intent**("android.media.action.IMAGE_CAPTURE");
        		try {
        			fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
        		} catch (IOException e) {
        			// TODO Auto-generated catch block
        			e.printStackTrace();
        		}
        		intent.putExtra(**MediaStore**.EXTRA_OUTPUT, fileUri);
        		startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
        
        	}
        
        	@Override
        	**protected void onActivityResult**(int requestCode, int resultCode, Intent data) {
        		if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
        			if (resultCode == RESULT_OK) {
        				StoreImage(this, data.getData(),
        						mediaFile);
        				 	finish();
        		           
        			} else if (resultCode == RESULT_CANCELED) {
        				// User cancelled the image capture
        			} else {
        				finish();
        				try {
        					
        				} catch (Exception e) {
        					e.printStackTrace();
        				}
        	}
        			
        			
        		}
        		
        	}

