programmatically send email with data file attachment

by Genesio » Wed, 10 Dec 2008 03:41:39 GMT


Sponsored Links
 Hello to everybody, i am writing a small program which creates a text
file on the external storage (microSD card).
Now i want to send this small file via email (asking the user which
account to use).

I read the sdk docs and I found that with an Intent and this action
( http://code.google.com/android/reference/android/content/ 
Intent.html#ACTION_SENDTO) I can write an email.
But I cannot find any EXTRA_**** to specify an attachment.

I tried with EXTRA_STREAM and an open FileInputStream pointing to the
txt file, but when I see (for example) gmail popping out (basic email
writing works) there is no attachment in the "pre-built" email.

I know this is possible because I installed an application from the
market (Voice Recorder) that already does it.

I would want to reproduce its behaviour.

P.S. Another way to achieve my goal would be to upload via HTTP the
file to a webserver... maybe it's simpler? anyone can give me an
example or show me a JAVA library that implements this functionality??

Thank you
Genesio


--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. CheckedTextView - only can select once checkbox

I'm really frusterated at this point, three days in.  I've put many
hours into this issu and am no closer to having a working (let alone
proper) solution.  Why is this so painful to accomplish I wonder
aloud.

Problem:

I've got a a ListView which has a row.xml for each row in the
ListView.  That file has two TextView's, ImageView, and a
CheckedTextView.

Now, I can get one CheckedTextView to become checked by pressing on
its UI area.  But, I cannnot not check any other unchecked checkbox in
the ListView.

Further more I see checkboxes when I scroll down that have checkmarks
in them where I did not check such myself.

So, what is the issue?  One of you google engineers surely can explain
this to us end-devs, better yet please supply a sample project.  I
have each row also where the user can select a file and work is done
with it when that path is pasted back to the main activity (which
works fine).

I have half the hair I had 72 hours ago (because I pulled half out).
Please, please help those of us struggling with this important feature
(CheckedTextView).  As I see several posts about this, anything from
implement Clickable on the class (which I did, both trying on the main
java file and as a helper class) to CheckedTextView has to be the
parent in the xml file (not say a LinearLayout for example).

Please...... help... drowing ..... in ... stess.

Thank you

-- 

2. source code help - reading framebuffer using glReadPixels

Hi,

I am new to Android development and working on an assignment to read
the framebuffer after some time interval and save it as an image.
I have come up with the following code initially only for reading and
saving the framebuffer, but this is not working and giving a run time
error. The emulator says that "the application stopped unexpectedly,
Please try again"

This is the current code: (I am using the Android 2.2 with API level 8
virtual device for testing, I don't have a physical device at the
moment)

public class mainActivity extends Activity
{
        Bitmap mSavedBM;
        private EGL10 egl;
    private EGLDisplay display;
    private EGLConfig config;
    private EGLSurface surface;
    private EGLContext eglContext;
    private GL11 gl;
    protected int width, height;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        // get the screen width and height
        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        int screenWidth = dm.widthPixels;
        int screenHeight = dm.heightPixels;

        String SCREENSHOT_DIR = "/screenshots";
        initGLFr(); //GlView initialized.
        savePixels( 0, 10, screenWidth, screenHeight, gl); //this gets
the screen to the mSavedBM.
        saveBitmap(mSavedBM, SCREENSHOT_DIR, "capturedImage");

        //Now we need to save the bitmap (the screen capture) to some
location.
        setContentView(R.layout.main); //This displays the content on
the screen

    }
    private void initGLFr()
    {
        egl = (EGL10) EGLContext.getEGL();
        display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
        int[] ver = new int[2];
        egl.eglInitialize(display, ver);

        int[] configSpec = {EGL10.EGL_NONE};
        EGLConfig[] configOut = new EGLConfig[1];
        int[] nConfig = new int[1];
        egl.eglChooseConfig(display, configSpec, configOut, 1,
nConfig);
        config = configOut[0];
        eglContext = egl.eglCreateContext(display, config,
EGL10.EGL_NO_CONTEXT, null);
        surface = egl.eglCreateWindowSurface(display, config,
SurfaceHolder.SURFACE_TYPE_GPU, null);
        egl.eglMakeCurrent(display, surface, surface, eglContext);
        gl = (GL11) eglContext.getGL();
    }
    public void savePixels(int x, int y, int w, int h, GL10 gl)
    {
        if (gl == null)
                return;

         synchronized (this) {
         if (mSavedBM != null) {
         mSavedBM.recycle();
         mSavedBM = null;
         }
         }

        int b[] = new int[w * (y + h)];
        int bt[] = new int[w * h];
        IntBuffer ib = IntBuffer.wrap(b);
        ib.position(0);
        gl.glReadPixels(x, 0, w, y + h,
GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,ib);

        for (int i = 0, k = 0; i < h; i++, k++)
        {
                //OpenGLbitmap is incompatible with Android bitmap
            //and so, some corrections need to be done.
                for (int j = 0; j < w; j++)
                {
                        int pix = b[i * w + j];
                        int pb = (pix >> 16) & 0xff;
                        int pr = (pix << 16) & 0x00ff0000;
                        int pix1 = (pix & 0xff00ff00) | pr | pb;
                        bt[(h - k - 1) * w + j] = pix1;
                }
        }

        Bitmap sb = Bitmap.createBitmap(bt, w, h,
Bitmap.Config.ARGB_8888);
        synchronized (this)
        {
                mSavedBM = sb;
        }
    }

    static String saveBitmap(Bitmap bitmap, String dir, String
baseName) {
        try {
            File sdcard = Environment.getExternalStorageDirectory();
            File pictureDir = new File(sdcard, dir);
            pictureDir.mkdirs();
            File f = null;
            for (int i = 1; i < 200; ++i) {
                String name = baseName + i + ".png";
                f = new File(pictureDir, name);
                if (!f.exists()) {
                    break;
                }
            }
            if (!f.exists()) {
                String name = f.getAbsolutePath();
                FileOutputStream fos = new FileOutputStream(name);
                bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
                fos.flush();
                fos.close();
                return name;
            }
        } catch (Exception e) {

        } finally {
            /*
            if (fos != null) {
                fos.close();
            }
            */
        }
        return null;
    }
}


Also, if someone can point me to sample code/tutorial to get this work
done through the NDK r4. I have read that the NDK r4 supports the
opengl es 1.1 and 2.0.
the framebuffer directly using the "/dev/graphics/fb0".


Thanks,

-- 

3. prob in attaching txt file while email from internal package file storage

4. How to parse the xml from a httpresponse?

5. automatically turn on application

6. Converting audio format

7. Why Activity with Translucent background can not finish immediately?