On Sat, Jun 27, 2009 at 3:58 PM, Mark Murphy<[email protected]> wrote:
>
> silverburgh wrote:
>> On Fri, Jun 26, 2009 at 5:29 PM, Mark Murphy<[email protected]> wrote:
>>> silverburgh wrote:
>>>> I create a local file in my activity like this:
>>>>
>>>> File f = getFileStreamPath("mypicture");
>>>>
>>>> How can I pass the URI of this file to another Activity?
>>> If the other activity is one in your application, just tell it the path
>>> from the File object, or the relative path you started with.
>>>
>>> If the other activity is outside your application, you can use
>>> File#getAbsolutePath() to get the fully-qualified path.
>>>
>>>> And do I need to set any permission (file permission, manifest
>>>> permission) to allow other Activity to use that file?
>>> You can try MODE_WORLD_READABLE and MODE_WORLD_WRITEABLE with
>>> openFileOutput() when you create the file, but I have not tried these.
>>> By default, other applications cannot access your file in your app-local
>>> file storage area.
>>
>>
>> Thanks. But I need help in combine your 2 ideas together.
>>
>> In creating file using MODE_WORLD_READABLE , it returns a reference of
>> FileOutputStream, not File, how can i get call the getAbsolutePath?
>
> File f = getFileStreamPath("mypicture");
>
> Just because you use openFileOutput() does not mean you are forevermore
> blocked from calling getFileStreamPath(). Just call getFileStreamPath()
> on the file you just created.
>
Thank you. I appreciate your help. I tried your suggestions. But I
still cant' get it to work.
I am trying to launch ACTION_IMAGE_CAPTURE activity using the
MediaStore.EXTRA_OUTPUT parameter to specify the URL of the captured
image.
Here is my code, but my activity's protected void onActivityResult()
never get called.
Can you please tell me what am I doing wrong?
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE, null);
File f = getFileStreamPath("temp-picture");
(new File(f.getParent())).mkdirs();
String mTempFilePath = f.getAbsolutePath();
f.delete();
FileOutputStream fos =null;
try {
fos = openFileOutput ("temp-picture", MODE_WORLD_WRITEABLE);
} catch (FileNotFoundException e) {
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
}
}
}
i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse("file:/" + mTempFilePath));
i.putExtra("outputFormat", Bitmap.CompressFormat.PNG.name());
System.out.println ("************ catpure
picture 4");
// i.putExtra("crop", "circle");
//i.putExtra("return-data", true);
startActivityForResult(i, PICK_ICON_FROM_CAMERA_ID);
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Android App Developer Books: http://commonsware.com/books.html
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---