Discussion:
Get the URI of audio files(.mp3) stored in raw folder
Kartik Domadiya
2011-11-01 12:52:35 UTC
Permalink
I want to send .mp3 file via mail (using share intent).

I have tried the following code :

Intent share = new Intent(Intent.ACTION_SEND);
share.setType("*/*");
share.putExtra(Intent.EXTRA_STREAM,Uri.parse("android.resource://
com.my.android.package/"+resId));
startActivity(Intent.createChooser(share, "Share Sound"));

Log of Uri.parse("android.resource://com.my.android.package/"+resId)
shows the below string :

android.resource://com.my.android.package/2130968609

When i select any mail application, the audio file(.mp3) gets
attached with resourceId.mp3 file (2130968609). I dont want that.

I want to get fileName.mp3. I want something like android.resource://
com.my.android.package/fileName.mp3. So that user can recognize the
file they wanted to share.

How can i do that ?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Kartik Domadiya
2011-11-02 11:01:12 UTC
Permalink
Finally after searching a lot i found the solution.

If you want to get any resource URI then there are two ways :

Using Resource Name

Syntax : android.resource://[package]/[res type]/[res name]

Example : Uri.parse("android.resource://com.segf4ult.test/drawable/
icon");

Using Resource Id

Syntax : android.resource://[package]/[resource_id]

Example : Uri.parse("android.resource://com.segf4ult.test/" +
R.drawable.icon);

This were the examples to get the URI of any image file stored in
drawable folder.

Similarly you can get URIs of res/raw folder.

In my case i used 1st way ie. Using Resource Name
Post by Kartik Domadiya
I want to send .mp3 file via mail (using share intent).
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("*/*");
share.putExtra(Intent.EXTRA_STREAM,Uri.parse("android.resource://
com.my.android.package/"+resId));
startActivity(Intent.createChooser(share, "Share Sound"));
Log of Uri.parse("android.resource://com.my.android.package/"+resId)
android.resource://com.my.android.package/2130968609
When i select any mail application, the audio file(.mp3)  gets
attached with resourceId.mp3 file (2130968609). I dont want that.
I want to get fileName.mp3. I want something like android.resource://
com.my.android.package/fileName.mp3. So that user can recognize the
file they wanted to share.
How can i do that ?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
arnouf
2011-11-02 12:19:26 UTC
Permalink
I don't know why you add in /res/raw, but maybe it could more interesting
to put these files in assets.
Maybe you can set a specific name building your shareintent.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Kartik Domadiya
2011-11-02 11:02:00 UTC
Permalink
Finally after searching a lot i found the solution.

If you want to get any resource URI then there are two ways :

Using Resource Name

Syntax : android.resource://[package]/[res type]/[res name]

Example : Uri.parse("android.resource://com.segf4ult.test/drawable/
icon");

Using Resource Id

Syntax : android.resource://[package]/[resource_id]

Example : Uri.parse("android.resource://com.segf4ult.test/" +
R.drawable.icon);

This were the examples to get the URI of any image file stored in
drawable folder.

Similarly you can get URIs of res/raw folder.

In my case i used 1st way ie. Using Resource Name
Post by Kartik Domadiya
I want to send .mp3 file via mail (using share intent).
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("*/*");
share.putExtra(Intent.EXTRA_STREAM,Uri.parse("android.resource://
com.my.android.package/"+resId));
startActivity(Intent.createChooser(share, "Share Sound"));
Log of Uri.parse("android.resource://com.my.android.package/"+resId)
android.resource://com.my.android.package/2130968609
When i select any mail application, the audio file(.mp3)  gets
attached with resourceId.mp3 file (2130968609). I dont want that.
I want to get fileName.mp3. I want something like android.resource://
com.my.android.package/fileName.mp3. So that user can recognize the
file they wanted to share.
How can i do that ?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Loading...