Open gmail attachments (xml) with another App

by Ben Caldwell » Fri, 07 Aug 2009 09:22:46 GMT


Sponsored Links
 My app uses the below intent filter to make itself an xml file reader
for the purpose of inserted data shared between users. This works fine
with xml files viewed in the browser but I can not make it work with
xml files sent as email attachments in the gmail app.

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="text/xml" />
</intent-filter>

When I check the logcat output I can see that the gmail app starts
downloading the attachment when I press the "Preview" button, but as
soon as my activity is brought to the front the attachment download is
cancelled and there is no data to parse.

I see in the intent created from the gmail app there are a couple of
ID numbers for the attachment. Perhaps someone has used these ID
numbers to grab file attachments from the gmail servers?

Anyone interested in how I am handling XML files so far please feel
free to peruse the source of my project at
 http://code.google.com/p/bites-android/source/browse/trunk/Bites/ 
--~--~---------~--~----~------------~-------~--~----~



Open gmail attachments (xml) with another App

by Ben Caldwell » Sun, 09 Aug 2009 07:28:01 GMT


 OK, I've got this working and it wasn't so hard after all!

Thanks go to Alexey Krasnoriadtsev whose post got me heading in the
right direction -


Sponsored Links


Other Threads

1. Zephyr HxM BT and HTC Legend Bluetooth issues

Hi,

I have bought myself a Zephyr HxM BT device and I am trying to listen to its
messages in a simple application.
I have paired the Device to my HTC Legend and I can establish a connection
but everytime I call the read() or available() method on my InputStream I
get a NullPointerException.

Has anyone succeed in getting information off this device?  I have tried to
establish the connection by reflection on the "createRfcommSocket" method
but this throws a MethodNotFound Exception on my device.
Any help would be appreciated.
Thanks,
Dennis

below is my Listener class:
HXMListener(BluetoothDevice device) {
            this.device = device;
            this.open = true;
            if (device != null){
                createSocket(device);
            }
        }

        /**
         * @param device
         */
        private void createSocket(BluetoothDevice device) {
            try {

                socket = device.createRfcommSocketToServiceRecord(HXM_UUID);
                in = socket.getInputStream();
                /**
                 * BluetoothDevice hxm =
                 * BluetoothAdapter.getDefaultAdapter().getRemoteDevice
                 * ("00:07:80:97:62:a3"); Method m =
                 * hxm.getClass().getMethod("createRfcommSocket", new
                 * Class[]{int.class}); socket =
(BluetoothSocket)m.invoke(hxm,
                 * Integer.valueOf(1)); socket.connect();
                 */
            } catch (IOException e) {
                Log.d(TAG,
                        "Unable to open Socket streams for " + socket);
                writeToHXMFile("Unable to open Socket streams for " +
socket);
                // tidy up the socket
                try {
                    if (socket != null) {
                        socket.close();
                    }
                } catch (IOException e1) {
                    Log.d(TAG,
                            "Unable to close Socket for " + socket);
                }
            }
        }

        private void connectionFailed() {
            Log.d(TAG, "Connection Failed");
            writeToHXMFile("Connection Failed");
        }

        /*
         * (non-Javadoc)
         *
         * @see java.lang.Runnable#run()
         */
        @Override
        public void run() {
            boolean connected = false;
            while (!connected && open) {
                try {
                    socket.connect();
                    connected = true;
                } catch (IOException e) {
                    connectionFailed();
                    Log.d(TAG, "Failed", e);
                    // Close the socket
                    try {
                        socket.close();
                    } catch (IOException e2) {
                        Log.d(
                                TAG,
                                "unable to close() "
                                        + "socket during connection failure"
                                        ,e);
                    }

                }
                finally{
                    createSocket(device);

                }
            }
            byte[] b = new byte[1];
            while(open){
                writeToHXMFile("Listening...");
                try {
//                    //FIXME in.available keeps throwing a null pointer
//                    while(open && in.available()<0){
//                        Thread.currentThread();
//                        Thread.sleep(10);
////                        Log.d(TAG, "Waiting...");
//                    }
                    //now we have the message lets read it to this
                    String s = "";
//                    while(open && in.available()>0){
                        s+= in.read(b);
//                    }
                    //now we have read it all
                    Log.d(TAG+"_INPUT", s);
                    writeToHXMFile("COMPLETE "+ s);
                } catch (IOException e) {
                    Log.d(TAG, "IO Exception ", e);
                    writeToHXMFile("IO Excep" + e);
                    open = false;

                }


            }
            try {
                in.close();
                socket.close();
            } catch (IOException e) {
                in = null;
                socket = null;
            }
        }



        private void writeToHXMFile(final String string) {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    bluetoothMessageBox.setText(string);
                    Log.d("SOCKET MESSAGE",string);
                }
            });

        }

        public void close() {
            open = false;
        }

    }

-- 

2. Sending UDP's

Hey guys, working on a project and have run into a problem that we've
been working on for a couple of days.  We are trying to send a UDP
from the Android emulator out to a Robot dog that has a wifi card.
When we run the program as a simple java applet, it works perfectly.
The way it should work is the robot dog should receive the udp from
the emulator, and it will trigger the dog to start sending video feed
back to the emulator at about 30 fps.  each frame is a jpeg image, so
each image is sent in one UDP.  When we run the program just as a java
applet, the program runs fine and the dog starts sending back UDP
packets.  However, when we run it in the Emulator, the dog never
responds, we assume because it never gets the initial UDP packet.  We
believe this is a problem with the emulator and may have something to
do with the port, but we have been messing with port forwarding and
still have had no luck.  We have also been using Wireshark to analyze
the output of the emulator.  thanks for any tips you have.  let me
know if you need more information

-- 

3. Trace flow of method call on android for implementing for JVMTI

4. Ad Hoc/Netfilter

5. Regarding language support

6. HTC Hero Error Downgrade

7. Compile problem, possibly porting issue