MIUI Camera - Intent issues

Discussion in 'Question & Answers' started by TheKeiron, Oct 31, 2011.

  1. TheKeiron

    TheKeironMembers

    Oct 31, 2011
    1
    0
    11
    I'm trying to make an app that launches the camera and will retrieve the photo that the camera takes

    After firing off the camera I retrieve the data like so:

    Code:
    @Override
    	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    		if(requestCode == CAMERA_PIC_REQUEST)
    		{
    			if(resultCode == RESULT_OK)
    			{
    				Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); 
    				myImageView.setImageBitmap(thumbnail);
    my app works on android phones with other camera apps but it looks like the miui camera app uses different intent data to the usual camera apps (trying to get "data" from the extras breaks it i.e. it looks like they use different terms)

    Is the camera app open source? If so, where can i access the source so i can see the intent string keys to retrieve the photo from the activity result?

    If the camera app is closed source, where can i get a list of the string keys to get the extras from the returned intent?

    EDIT: Ok I have now discovered the result intent returned from the miui camera has NO EXTRAS which is why its failing with this code. I am trying to work out how to retrieve the photo it has taken now from whatever else is in the passed reult intent.

    EDIT2: After some further investigation I discovered the returned intent actually contains a path to the image on the sd card so i have edited my onActivityResult method to retrieve the path from the intent using 'data.getData().getPath()' like so:

    Code:
    @Override
    	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    		// TODO Auto-generated method stub
    		if(requestCode == CAMERA_PIC_REQUEST)
    		{
    			if(resultCode == RESULT_OK)
    			{
    				if(data.hasExtra("data"))
    				{
    					Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); 
    					myImageView.setImageBitmap(thumbnail);
    				}
    				else if(data.getExtras()==null)
    				{
    					Toast.makeText(getApplicationContext(), "No extras to retrieve!",Toast.LENGTH_SHORT).show();
    					
    					BitmapDrawable thumbnail = new BitmapDrawable(getResources(), data.getData().getPath()); 
    					myImageView.setImageDrawable(thumbnail); 
    					
    				}
    				
    				
    			}
    			else if (resultCode == RESULT_CANCELED)
    			{
    				Toast.makeText(getApplicationContext(), "Cancelled",Toast.LENGTH_SHORT).show();
    			}
    			
    		}
    	}
    
    This code works fine :)
     

Share Our Site