Works in emulator but causes force close on handset?
<p>I'm sending a class via serialization on a button press. Here is the code:</p>

<pre><code>    final SerializeAndSend ss = new SerializeAndSend();

    final Button button = (Button) findViewById(R.id.button1);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v){
            ss.sendIt();            
        }
    });
</code></pre>

<p>Here is the send class:</p>

<p>public class SerializeAndSend {</p>

<pre><code>public void sendIt(){

      my.app.DataContainer e = new my.app.DataContainer();
      e.userName="AppTest";
      e.hashedPassword="goog3-8498";

      sendObject(e);

}

public Object sendObject(Object obj) {
    URLConnection conn = null;
    Object reply = null;
    try {

        // open URL connection
        URL url = new URL("//myApp//");
        conn = url.openConnection();
        conn.setDoInput(true);
        conn.setDoOutput(true);
        conn.setUseCaches(false);
        // send object
        ObjectOutputStream objOut = new ObjectOutputStream(conn.getOutputStream());
        objOut.writeObject(obj);
        objOut.flush();
        objOut.close();
    } catch (IOException ex) {
        ex.printStackTrace();
        return null;
    }
    // recieve reply
    try {
        ObjectInputStream objIn = new ObjectInputStream(conn.getInputStream());
        reply = objIn.readObject();
        objIn.close();
    } catch (Exception ex) {
        // it is ok if we get an exception here
        // that means that there is no object being returned
        System.out.println("No Object Returned");
        if (!(ex instanceof EOFException))
            ex.printStackTrace();
            System.err.println("*");
    }
    return reply;
}
</code></pre>

<p>}</p>

<p>This works well on my machine, on the emulator. But when I try it on my handset, an Xperia - it forces close. Is there a specific reason for this in my code, am I doing something you shouldn't. Or is it just my handset? </p>

<p>The logCat, thanks for pointing this out to me, I think this is the part that you want to see:</p>

<pre><code>I/ActivityManager(  290): Force stopping package my.app.app uid=10009
I/ActivityManager(  290): Killing proc 24393:my.app.app/10009: force stop
I/ActivityManager(  290):   Force finishing activity ActivityRecord{2c3d8ff0 my.app.app/.SplashScreen}
I/ActivityManager(  290):   Force finishing activity ActivityRecord{2bbd6888 my.app.app/.SplashScreen}
I/WindowManager(  290): WIN DEATH: Window{2bf5d9b8 my.app.app/my.app.app.SplashScreen paused=true}
I/PackageManager(  290): Package my.app.app codePath changed from /data/app/my.app.app-2.apk to /data/app/my.app.app-1.apk; Retaining data and using new
I/ActivityManager(  290): Force stopping package my.app.app uid=10009
W/PackageManager(  290): Code path for pkg : my.app.app changing from /data/app/my.app.app-2.apk to /data/app/my.app.app-1.apk
W/PackageManager(  290): Resource path for pkg : my.app.app changing from /data/app/my.app.app-2.apk to /data/app/my.app.app-1.apk
I/ActivityManager(  290): Force stopping package my.app.app uid=10009
D/BackupManagerService(  290): Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:my.app.app flg=0x10000010 (has extras) }
D/BackupManagerService(  290): Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:my.app.app flg=0x10000010 (has extras) }
D/BackupManagerService(  290): Received broadcast Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:my.app.app flg=0x10000010 (has extras) }
I/ActivityManager(  290): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=my.app.app cmp=my.app.app/.SplashScreen} from pid 24601
I/ActivityManager(  290): Start proc my.app.app for activity my.app.app/.SplashScreen: pid=24814 uid=10009 gids={3003, 1015}
    E/AndroidRuntime(24833): at my.app.SerializeAndSend.sendObject(SerializeAndSend.java:35)
    E/AndroidRuntime(24833): at my.app.SerializeAndSend.sendIt(SerializeAndSend.java:19)
    E/AndroidRuntime(24833): at my.app.app.SplashScreen$1.onClick(SplashScreen.java:46)
    W/ActivityManager(  290):   Force finishing activity my.app.app/.SplashScreen
</code></pre>

<p>I think its this line causing the error:</p>

<pre><code>ObjectOutputStream objOut = new ObjectOutputStream(conn.getOutputStream());
</code></pre>
