How to pass a URI to an intent?

前端 未结 8 768
日久生厌
日久生厌 2020-11-27 11:50

I\'m trying to pass a URI-Object to my Intent in order to use that URI in another activity...

How do I pass a URI ?

private Uri imageUri;
....
Intent         


        
8条回答
  •  庸人自扰
    2020-11-27 12:22

    In Intent, you can directly put Uri. You don't need to convert the Uri to string and convert back again to Uri.

    Look at this simple approach.

    // put uri to intent 
    intent.setData(imageUri);
    

    And to get Uri back from intent:

    // Get Uri from Intent
    Uri imageUri=getIntent().getData();
    

提交回复
热议问题