On Fri, Feb 17, 2012 at 6:38 PM, Mark Murphy <mmur...@commonsware.com> wrote:
> You can specify the path to a PDF as an extra, or as the Uri > associated with the Intent. You need to follow the rules for whatever > it is that you are trying to do (e.g., ACTION_SEND would use > EXTRA_STREAM). > > Note that paths to files on internal storage are frequently useless, > as other apps cannot access those files by default. You would either > need to use MODE_WORLD_READABLE (ick) or create a small > ContentProvider for serving that file and making it available to other > apps via a content:// Uri. I've found the following code which would allow the user to select an email client from a list fired as an intent. The email client on the phone would have the pdf as an attachment. Here the pdf is called shortcuts.pdf. However I don't know how to save it so that it becomes accessible as R.raw.shortcuts . How is this magic achieved? What is R.raw? Does it reside on external storage? Do I really need to use "content://" and a content provider or can I do away with using "android:resource://" as below? What's the difference? Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"emailaddress"}); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Body"); String rawFolderPath = "android.resource://" + getPackageName() + "/" + R.raw.shortcuts; // Here my file name is shortcuts.pdf which i have stored in /res/raw folder Uri emailUri = Uri.parse(rawFolderPath ); emailIntent.putExtra(Intent.EXTRA_STREAM, emailUri); emailIntent.setType("application/pdf"); startActivity(Intent.createChooser(emailIntent, "Send mail...")); Thanks, JG -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en