Transmit serialized object via HTTP in Android

by Ray da Costa » Mon, 22 Feb 2010 19:57:19 GMT


Sponsored Links
 Hi

Personnel possibility exists to transmit serialized object via HTTP in
Android? I'm trying to use the HttpURLConnection but I get an exception
saying that does not support

-- 
Ray da Costa
"The best way to predict the future is to invent it."
Alan Kay

--



Other Threads

1. data passed to handler overwritten?

I'm passing data to a Handler for drawing in the UI thread. On of the
pieces of code below. The DrawPolygon function is called from my code,
and has the right data for the three calls. The DrawPolygonHandler
however is executed three times but each time with the data for the last
call.

Am I missing something obvious ?

        Danny

        class PolygonData {
                int     count;
                int     filled;
                float[] points;
        };

        Handler DrawPolygonHandler = new Handler() {
                @Override
                public void handleMessage(Message msg) {
                        PolygonData     p = (PolygonData)msg.obj;
                        float[] points = p.points;
                        int     filled = msg.what,
                                count = msg.arg1;

                        Log.e("RoadMap", "DrawPolygonHandler {"
                                        + msg
                                        + "} count " + count + " filled
" + filled);
                        Log.e("RoadMap", "DPHandler point 0 {"
                                        + p.points[0] + "," +
p.points[1] + "}");
                        try {
                                int i;
                                Canvas canvas =
getHolder().lockCanvas();
                                paint = pen.GetPaint();

                                if (filled == 1)

paint.setStyle(Paint.Style.FILL_AND_STROKE);
                                else

paint.setStyle(Paint.Style.STROKE);
                
                                Path path = new Path();
                        
                                Log.e("RoadMap", "Polygon pt 0 [" +
points[0] + "," + points[1] + "]");                     
                                path.moveTo(points[0], points[1]);
                                for (i=2; i<2*count; i+=2) {
                                        path.lineTo(points[i], points[i
+1]);
                                        Log.e("RoadMap", "Polygon pt " +
i + " ["
                                                        + points[i] +
"," + points[i+1] + "]");
                                }

                                path.close();
                                canvas.drawPath(path, paint);
                
                                getHolder().unlockCanvasAndPost(canvas);
                        } catch (Exception e) {
                                Log.e("RoadMap", "Exception " + e + " in
DrawPolygon");
                        }       
                }               
        };      

        public void DrawPolygon(int filled, int count, float[] points)
        {       
                PolygonData p = new PolygonData();
                        
                p.count = count;
                p.filled = filled;
                p.points = points;

                Message m = DrawPolygonHandler.obtainMessage();
                m.what = filled;
                m.arg1 = count;
                m.arg2 = 0;
                m.obj = (Object)p;

                DrawPolygonHandler.sendMessage(m);
                Log.e("RoadMap", "DrawPolygon {"
                                + m
                                + "} count " + count +
                                ", first point [" + points[0] + "," +
points[1] + "]");
        }

E/RoadMap ( 5782): draw_polygon - line 0 has 4 points
E/RoadMap ( 5782):  - line 0 point 0 - 10 95
E/RoadMap ( 5782):  - line 0 point 1 - 17 88
E/RoadMap ( 5782):  - line 0 point 2 - 20 95
E/RoadMap ( 5782):  - line 0 point 3 - 18 97
E/RoadMap ( 5782): draw_polygon - line 1 has 4 points
E/RoadMap ( 5782):  - line 1 point 0 - 25 100
E/RoadMap ( 5782):  - line 1 point 1 - 32 103
E/RoadMap ( 5782):  - line 1 point 2 - 25 110
E/RoadMap ( 5782):  - line 1 point 3 - 22 103
E/RoadMap ( 5782): draw_polygon - line 2 has 4 points
E/RoadMap ( 5782):  - line 2 point 0 - 25 90
E/RoadMap ( 5782):  - line 2 point 1 - 30 95
E/RoadMap ( 5782):  - line 2 point 2 - 20 105
E/RoadMap ( 5782):  - line 2 point 3 - 15 100
E/RoadMap ( 5782): DrawPolygon {{ what=1 when=143096293 arg1=4
obj=net.sourceforge.projects.roadmap.panel$polygond...@43de5ca8 }} count
4, first point [10.0,95.0]
E/RoadMap ( 5782): DrawPolygon {{ what=1 when=143096295 arg1=4
obj=net.sourceforge.projects.roadmap.panel$polygond...@43de6ce8 }} count
4, first point [25.0,100.0]
E/RoadMap ( 5782): DrawPolygon {{ what=1 when=143096297 arg1=4
obj=net.sourceforge.projects.roadmap.panel$polygond...@43de7a88 }} count
4, first point [25.0,90.0]
E/RoadMap ( 5782): DrawPolygonHandler {{ what=1 when=143096293 arg1=4
obj=net.sourceforge.projects.roadmap.panel$polygond...@43de5ca8 }} data
{net.sourceforge.projects.roadmap.panel$polygond...@43de5ca8} count 4
filled 1
E/RoadMap ( 5782): DPHandler point 0 {25.0,90.0}
E/RoadMap ( 5782): Polygon pt 0 [25.0,90.0]
E/RoadMap ( 5782): Polygon pt 2 [30.0,95.0]
E/RoadMap ( 5782): Polygon pt 4 [20.0,105.0]
E/RoadMap ( 5782): Polygon pt 6 [15.0,100.0]
E/RoadMap ( 5782): DrawPolygonHandler {{ what=1 when=143096295 arg1=4
obj=net.sourceforge.projects.roadmap.panel$polygond...@43de6ce8 }} data
{net.sourceforge.projects.roadmap.panel$polygond...@43de6ce8} count 4
filled 1
E/RoadMap ( 5782): DPHandler point 0 {25.0,90.0}
E/RoadMap ( 5782): Polygon pt 0 [25.0,90.0]
E/RoadMap ( 5782): Polygon pt 2 [30.0,95.0]
E/RoadMap ( 5782): Polygon pt 4 [20.0,105.0]
E/RoadMap ( 5782): Polygon pt 6 [15.0,100.0]
E/RoadMap ( 5782): DrawPolygonHandler {{ what=1 when=143096297 arg1=4
obj=net.sourceforge.projects.roadmap.panel$polygond...@43de7a88 }} data
{net.sourceforge.projects.roadmap.panel$polygond...@43de7a88} count 4
filled 1
E/RoadMap ( 5782): DPHandler point 0 {25.0,90.0}
E/RoadMap ( 5782): Polygon pt 0 [25.0,90.0]
E/RoadMap ( 5782): Polygon pt 2 [30.0,95.0]
E/RoadMap ( 5782): Polygon pt 4 [20.0,105.0]
E/RoadMap ( 5782): Polygon pt 6 [15.0,100.0]




-- 
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info

-- 

2. Suhi Beraks

*soja sambil bungkukkin badan wongompong



> 

3. Update :) WTA: Desire kalo YouTube restart

4. how to know the device priority in FROYO ?

5. WT Share : Step by step SimpleRoot OTA 1.47.651.1 Untuk HTC EVO 4G

6. HttpPost and byte[] on Android?

7. problem accessing widget in Preference widgetLayout