1

So i have coded a few script that uses URI. However there are a lot of complaints that the function not working in Xiaomi / Redmi / huawei. This coded are tested and work well within emulator. Get filename and path from URI from mediastore No response on full screen activity (different android version?)

So any one have any suggestion / work around for this problem? Work around 1: To use assets folder(havent tried with picture, but mostly work-able, but not working with the video file.)

So far I narrow down my code to

videoUri = Uri.parse("android.resource://" + getPackageName() + "/raw/" + filename);

the above work only in emulator, not working in xiaomi / huawei
What can we do with this?

videoUri = Uri.parse("android.resource://" + getPackageName() + R.raw.filename);

the above works well in both emulator and real phone.

Anyone had any thought on this?

Trying 1
How to read file from res/raw by name

int videoID = getResources().getIdentifier("filename","raw", getPackageName());
videoUri = Uri.parse("android.resource://" + getPackageName() + "/" + 
videoID);

Result: Working with emulators, still not working with my Redmi Note 2

Tony Ming
  • 101
  • 1
  • 1
  • 11

1 Answers1

0

You need to use path like this:

"android.resource://" + getPackageName() + "/" + R.raw.filename;

The file should be stored under res/raw/filename and it should be of .mp4 type.

I have tested this on my Redmi note 3 and Redmi 3s prime phone.

EDIT

videoUri = Uri.parse("android.resource://"+getPackageName()+"/raw/"+"crop");

I have tested this on mentioned Redmi devices and it is working.

Rahul Khurana
  • 8,577
  • 7
  • 33
  • 60