How to make the Socket not disconnect from the server when you rotate the screen, or rather did not become null 'ohm? In principle, it would be possible to save it with the help of the Bundle , but for some reason, saving of all types there occurs in the String type ...

  private static final String autherised=null; @Override public void onSaveInstanceState(Bundle savedInstanceState) { savedInstanceState.putBoolean(autherised,true); super.onSaveInstanceState(savedInstanceState); } 

Therefore, it seems to me that with a complex object (Socket) such a trick will not work. So where should I save the Socket or where to create it so that its activity doesn’t touch its reboots?

    1 answer 1

    Take out all your network code in a separate Service and reboot the Activity will not affect it.

    • Well, I will try, and then how can I get the socket out of the service into a variable, when I restart the activation (screen flip)? - alex-rudenkiy
    • @ alex-rudenkiy stackoverflow.com/a/9959520/5634351 - Kirill Stoianov
    • The socket does not need to be passed to activate Transfer only the data itself. - Pioneer
    • And how can I transfer to the callback service "public interface"? Well, or, for example, at least some kind of class and something that could be activated from the service to get the contents of some kind of variable, and then I’ll finish it myself. - alex-rudenkiy
    • for example so stackoverflow.com/q/14985678 - Pioneer