android: how to register my app as “camera app”

前端 未结 2 1154
旧时难觅i
旧时难觅i 2020-12-31 18:17

I was wondering how to tell android that my app is a camera app, so other apps know that they can start my app to get a picture. E.g. with pixlr-o-matic you can either selec

2条回答
  •  独厮守ぢ
    2020-12-31 19:16

    This is done with intent-filters. Add the following tag to your manifest :

    
        
            
            
        
    
    

    Now your application will appear in the list when the user wants to take a picture.

    EDIT :

    Here is the proper way to return a bitmap :

    Uri saveUri = (Uri) getIntent().getExtras().getParcelable(MediaStore.EXTRA_OUTPUT);
    
    if (saveUri != null)
    {
        // Save the bitmap to the specified URI (use a try/catch block)
        outputStream = getContentResolver().openOutputStream(saveUri);
        outputStream.write(data); // write your bitmap here
        outputStream.close();
        setResult(RESULT_OK);
    }
    else
    {
        // If the intent doesn't contain an URI, send the bitmap as a Parcelable
        // (it is a good idea to reduce its size to ~50k pixels before)
        setResult(RESULT_OK, new Intent("inline-data").putExtra("data", bitmap));
    }
    

    You can also check the android built-in Camera app source code.

提交回复
热议问题