Display jpg image from intent in imageview

后端 未结 3 459
离开以前
离开以前 2021-01-22 08:36

How to display an Image received from an \"android.intent.action.SEND\" in an imageview? The user selects my app from the list of apps to share an imag

3条回答
  •  长情又很酷
    2021-01-22 09:08

    You are receving Image in Intent, So you have to update your Manifest as:

    
        ...
        ...
        
        ...
            
            
            
        
    

    Then Activity needs:

    void onCreate (Bundle savedInstanceState) {
    ...
    // Get intent, action and MIME type
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if (type.startsWith("image/")) {
            Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (imageUri != null) {
                YourImageView.setImageUri(imageUri);
            }
        }
    .
    .
    .
    

提交回复
热议问题