is there any hope to get file from intent URI receive outside of the application

I am trying to get the file from email attachment and and get it as content as in URI,

the code written in eclips runs fine and got the file from IOStream class but can not find any solution in Titanium….

Is there any alternate solution is posible for this problem??

var activity = Ti.Android.currentActivity;
var intentData = activity.getIntent().getData();

Eclips code running file and generate file from intent data….

public class MainActivityTest extends Activity {
    public void onCreate(Bundle savedInstanceState) {

        Intent intent = getIntent(); 
        Uri returned_uri = intent.getData();

        if (returned_uri == null) {

            Toast.makeText(getApplicationContext(), "Uri is Null",
        } else {
                try {
                if (getIntent().getScheme().equals("file")) {

                    String path = getIntent().getData().getPath();
                    File fileSource = new File(path);

                    System.out.println("File Path from SDCard >>>>> ***** : "+fileSource.getPath());

                    System.out.println("File Path from SDCard >>>>> $$$ : "+path);

                    if(fileSource.getPath().contains("/sdcard/com.logistic.demoopenfile/")) {
                                "Source and Destination are same", Toast.LENGTH_LONG)

                    File fileDest = new File("/sdcard/com.logistic.demoopenfile/","Resume.doc");


                            "File Imported from SDCard", Toast.LENGTH_LONG)

                } else if (!getIntent().getScheme().equals("content")) {

                    InputStream attachment = getContentResolver()

                    File wallpaperDirectory = new File(

                    FileOutputStream f = new FileOutputStream(new File(
                            "/sdcard/com.logistic.demoopenfile/", "resume.doc"));

                    byte[] buffer = new byte[1024];
                    int len1 = 0;
                    while ((len1 = > 0) {

                            "File Imported from Email Attachment",

            } catch (Exception e) {

    void copy(File src, File dst) throws IOException {
        InputStream in = new FileInputStream(src);
        OutputStream out = new FileOutputStream(dst);

        // Transfer bytes from in to out
        byte[] buf = new byte[1024];
        int len;
        while ((len = > 0) {
            out.write(buf, 0, len);

    public static String getContentName(ContentResolver resolver, Uri uri) {
        Cursor cursor = resolver.query(uri, null, null, null, null);
        System.out.println("Cursor count :" + cursor.getColumnCount());
        int nameIndex = cursor
        if (nameIndex >= 0) {
            return cursor.getString(nameIndex);
        } else {
            return null;

— asked 4 years ago by Gaurang Chhatbar
  • Hi Gaurang,

    did you find a solution for this?

    would be great if you could share it here!

    — commented 4 years ago by Roeland P
  • hi,

    if you see the AndroidManifest.custom.xml file part displayed in the given link, it will helpful for you and you can also get reference by for more customize settings, link is included at the last.

    just few things you have to remember that Android just include one intent for activity that you have to register first in AndroidManifest.xml. for that you can directly edit AndroidManifest.xml or make new AndroidManifest.custom.xml file place in root folder with resource folder.


    Its an advice to write new AndroidManifest.custom.xml rather than edit AndroidManifest.xml. just copy paste all AndroidManifest.xml in to new AndroidManifest.custom.xml and edit it directly. AndroidManifest.xml change causses the crash in application.

    — commented 4 years ago by Gaurang Chhatbar

0 Answers