socket service onBackPressed












0















when i press the system back button my app disconnects but i want to return back in this way :




i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);




I think there is an error in my Socket Service cause gaqve me this:



2018-11-16 11:54:45.869 6099-6099/com.app.ifarma I/SocketService: quit:
2018-11-16 11:54:45.871 6099-6099/com.app.ifarma W/System.err: java.net.SocketException: Socket is closed
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at java.net.Socket.getInputStream(Socket.java:930)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.closeConnection(SocketService.java:126)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.sendMessage(SocketService.java:115)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.Scollega$2.run(Scollega.java:71)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.handleCallback(Handler.java:789)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.os.Looper.loop(Looper.java:164)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6541)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
2018-11-16 11:54:45.873 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
2018-11-16 11:54:45.886 6099-6134/com.app.ifarma W/System.err: java.net.SocketException: Socket closed
2018-11-16 11:54:45.886 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead0(Native Method)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead(SocketInputStream.java:114)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:170)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:139)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:288)
2018-11-16 11:54:45.889 6099-6134/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:351)
2018-11-16 11:54:45.894 6099-6134/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
2018-11-16 11:54:45.898 6099-6134/com.app.ifarma W/System.err: at java.io.InputStreamReader.read(InputStreamReader.java:184)
2018-11-16 11:54:45.899 6099-6134/com.app.ifarma W/System.err: at java.io.BufferedReader.fill(BufferedReader.java:172)
2018-11-16 11:54:45.900 6099-6134/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:335)
2018-11-16 11:54:45.905 6099-6134/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:400)
2018-11-16 11:54:45.905 6099-6134/com.app.ifarma W/System.err: at com.app.ifarma.SocketService$ClientThread.run(SocketService.java:272)
2018-11-16 11:54:45.906 6099-6134/com.app.ifarma W/System.err: at java.lang.Thread.run(Thread.java:764)
2018-11-16 11:54:45.907 6099-6131/com.app.ifarma W/System.err: java.net.SocketException: Socket closed
2018-11-16 11:54:45.907 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead0(Native Method)
2018-11-16 11:54:45.908 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead(SocketInputStream.java:114)
2018-11-16 11:54:45.909 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:170)
2018-11-16 11:54:45.909 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:139)
2018-11-16 11:54:45.909 6099-6131/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:288)
2018-11-16 11:54:45.910 6099-6131/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:351)
2018-11-16 11:54:45.918 6099-6131/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
2018-11-16 11:54:45.918 6099-6131/com.app.ifarma W/System.err: at java.io.InputStreamReader.read(InputStreamReader.java:184)
2018-11-16 11:54:45.920 6099-6131/com.app.ifarma W/System.err: at java.io.BufferedReader.fill(BufferedReader.java:172)
2018-11-16 11:54:45.920 6099-6131/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:335)
2018-11-16 11:54:45.921 6099-6131/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:400)
2018-11-16 11:54:45.922 6099-6131/com.app.ifarma W/System.err: at com.app.ifarma.SocketService$ClientThread.run(SocketService.java:272)
2018-11-16 11:54:45.923 6099-6131/com.app.ifarma W/System.err: at java.lang.Thread.run(Thread.java:764)
2018-11-16 11:54:45.977 6099-6099/com.app.ifarma I/SocketService: quit:
2018-11-16 11:54:45.978 6099-6099/com.app.ifarma W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.OutputStream java.net.Socket.getOutputStream()' on a null object reference
2018-11-16 11:54:45.979 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.closeConnection(SocketService.java:125)
2018-11-16 11:54:45.979 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.sendMessage(SocketService.java:115)
2018-11-16 11:54:45.979 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.Scollega$2.run(Scollega.java:71)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.handleCallback(Handler.java:789)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.os.Looper.loop(Looper.java:164)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6541)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
2018-11-16 11:54:45.981 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)


this is my socketService(the problematic part):



@Override
public void onCreate() {
super.onCreate();
}

public void sendMessage(String message) {

line = "";

if (out != null && !out.checkError()) {
out.println(message);
out.flush();
Log.i("SocketService", "" + message.toString());
//ci aspettiamo una risposta solo se non e' quit
if (message.equals("quit:")) {
closeConnection();
}

}
}

public void closeConnection() {

try {
connect = false;
socket.getOutputStream().close();
socket.getInputStream().close();
socket.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}

socket = null;
}


Maybe also my "scollega" class has some problem



public class Scollega extends Activity {

public SocketService s;
//service
boolean mBounded;
ServiceConnection mConnection = new ServiceConnection() {

public void onServiceDisconnected(ComponentName name) {
mBounded = false;
s = null;
}

public void onServiceConnected(ComponentName name, IBinder service) {
mBounded = true;
LocalBinder mLocalBinder = (LocalBinder) service;
s = mLocalBinder.getServerInstance();
}
};

;

@Override
protected void onStart() {
super.onStart();
Intent mIntent = new Intent(this, SocketService.class);
bindService(mIntent, mConnection, BIND_AUTO_CREATE);
}

@Override
protected void onStop() {
super.onStop();
if (mBounded) {
unbindService(mConnection);
mBounded = false;
}
}

;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loader);
getWindow().setWindowAnimations(0);


TextView outputView = (TextView) findViewById(R.id.textLoader);
outputView.setText("Scollegamento...");

//creiamo il timeout dopo l'avvio del servizio
Handler handler = new Handler();
handler.postDelayed(new Runnable() {

@Override
public void run() {

try {
s.sendMessage("quit:");
} catch (Exception e) {
e.printStackTrace();
}


//torniamo in Home
Intent i = new Intent(Scollega.this, Home.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(i);
overridePendingTransition(R.anim.slide_left, R.anim.slide_right);
finish();
}
}, 1000); // ritardiamo l'esecuzione di un secondo

}


I inherited this program from a person who no longer wants to deal with it, I solved most of the problems but I do not know how to do this part...










share|improve this question

























  • please, post all service code.

    – Augusto
    Nov 16 '18 at 11:36











  • Using flag clear top If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

    – Piyush
    Nov 16 '18 at 11:37











  • One of the exception you are getting is because you are calling try { s.sendMessage("quit:"); } catch (Exception e) { e.printStackTrace(); } in onCreate without being sure the socket really connected so the property s is null

    – MatPag
    Nov 16 '18 at 11:38













  • Another thing is that in onStop method, you need to perform your cleanup actions before calling super.onStop(), so it should be if (mBounded) { unbindService(mConnection); mBounded = false; } super.onStop();

    – MatPag
    Nov 16 '18 at 11:42


















0















when i press the system back button my app disconnects but i want to return back in this way :




i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);




I think there is an error in my Socket Service cause gaqve me this:



2018-11-16 11:54:45.869 6099-6099/com.app.ifarma I/SocketService: quit:
2018-11-16 11:54:45.871 6099-6099/com.app.ifarma W/System.err: java.net.SocketException: Socket is closed
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at java.net.Socket.getInputStream(Socket.java:930)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.closeConnection(SocketService.java:126)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.sendMessage(SocketService.java:115)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.Scollega$2.run(Scollega.java:71)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.handleCallback(Handler.java:789)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.os.Looper.loop(Looper.java:164)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6541)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
2018-11-16 11:54:45.873 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
2018-11-16 11:54:45.886 6099-6134/com.app.ifarma W/System.err: java.net.SocketException: Socket closed
2018-11-16 11:54:45.886 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead0(Native Method)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead(SocketInputStream.java:114)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:170)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:139)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:288)
2018-11-16 11:54:45.889 6099-6134/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:351)
2018-11-16 11:54:45.894 6099-6134/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
2018-11-16 11:54:45.898 6099-6134/com.app.ifarma W/System.err: at java.io.InputStreamReader.read(InputStreamReader.java:184)
2018-11-16 11:54:45.899 6099-6134/com.app.ifarma W/System.err: at java.io.BufferedReader.fill(BufferedReader.java:172)
2018-11-16 11:54:45.900 6099-6134/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:335)
2018-11-16 11:54:45.905 6099-6134/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:400)
2018-11-16 11:54:45.905 6099-6134/com.app.ifarma W/System.err: at com.app.ifarma.SocketService$ClientThread.run(SocketService.java:272)
2018-11-16 11:54:45.906 6099-6134/com.app.ifarma W/System.err: at java.lang.Thread.run(Thread.java:764)
2018-11-16 11:54:45.907 6099-6131/com.app.ifarma W/System.err: java.net.SocketException: Socket closed
2018-11-16 11:54:45.907 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead0(Native Method)
2018-11-16 11:54:45.908 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead(SocketInputStream.java:114)
2018-11-16 11:54:45.909 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:170)
2018-11-16 11:54:45.909 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:139)
2018-11-16 11:54:45.909 6099-6131/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:288)
2018-11-16 11:54:45.910 6099-6131/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:351)
2018-11-16 11:54:45.918 6099-6131/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
2018-11-16 11:54:45.918 6099-6131/com.app.ifarma W/System.err: at java.io.InputStreamReader.read(InputStreamReader.java:184)
2018-11-16 11:54:45.920 6099-6131/com.app.ifarma W/System.err: at java.io.BufferedReader.fill(BufferedReader.java:172)
2018-11-16 11:54:45.920 6099-6131/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:335)
2018-11-16 11:54:45.921 6099-6131/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:400)
2018-11-16 11:54:45.922 6099-6131/com.app.ifarma W/System.err: at com.app.ifarma.SocketService$ClientThread.run(SocketService.java:272)
2018-11-16 11:54:45.923 6099-6131/com.app.ifarma W/System.err: at java.lang.Thread.run(Thread.java:764)
2018-11-16 11:54:45.977 6099-6099/com.app.ifarma I/SocketService: quit:
2018-11-16 11:54:45.978 6099-6099/com.app.ifarma W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.OutputStream java.net.Socket.getOutputStream()' on a null object reference
2018-11-16 11:54:45.979 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.closeConnection(SocketService.java:125)
2018-11-16 11:54:45.979 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.sendMessage(SocketService.java:115)
2018-11-16 11:54:45.979 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.Scollega$2.run(Scollega.java:71)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.handleCallback(Handler.java:789)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.os.Looper.loop(Looper.java:164)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6541)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
2018-11-16 11:54:45.981 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)


this is my socketService(the problematic part):



@Override
public void onCreate() {
super.onCreate();
}

public void sendMessage(String message) {

line = "";

if (out != null && !out.checkError()) {
out.println(message);
out.flush();
Log.i("SocketService", "" + message.toString());
//ci aspettiamo una risposta solo se non e' quit
if (message.equals("quit:")) {
closeConnection();
}

}
}

public void closeConnection() {

try {
connect = false;
socket.getOutputStream().close();
socket.getInputStream().close();
socket.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}

socket = null;
}


Maybe also my "scollega" class has some problem



public class Scollega extends Activity {

public SocketService s;
//service
boolean mBounded;
ServiceConnection mConnection = new ServiceConnection() {

public void onServiceDisconnected(ComponentName name) {
mBounded = false;
s = null;
}

public void onServiceConnected(ComponentName name, IBinder service) {
mBounded = true;
LocalBinder mLocalBinder = (LocalBinder) service;
s = mLocalBinder.getServerInstance();
}
};

;

@Override
protected void onStart() {
super.onStart();
Intent mIntent = new Intent(this, SocketService.class);
bindService(mIntent, mConnection, BIND_AUTO_CREATE);
}

@Override
protected void onStop() {
super.onStop();
if (mBounded) {
unbindService(mConnection);
mBounded = false;
}
}

;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loader);
getWindow().setWindowAnimations(0);


TextView outputView = (TextView) findViewById(R.id.textLoader);
outputView.setText("Scollegamento...");

//creiamo il timeout dopo l'avvio del servizio
Handler handler = new Handler();
handler.postDelayed(new Runnable() {

@Override
public void run() {

try {
s.sendMessage("quit:");
} catch (Exception e) {
e.printStackTrace();
}


//torniamo in Home
Intent i = new Intent(Scollega.this, Home.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(i);
overridePendingTransition(R.anim.slide_left, R.anim.slide_right);
finish();
}
}, 1000); // ritardiamo l'esecuzione di un secondo

}


I inherited this program from a person who no longer wants to deal with it, I solved most of the problems but I do not know how to do this part...










share|improve this question

























  • please, post all service code.

    – Augusto
    Nov 16 '18 at 11:36











  • Using flag clear top If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

    – Piyush
    Nov 16 '18 at 11:37











  • One of the exception you are getting is because you are calling try { s.sendMessage("quit:"); } catch (Exception e) { e.printStackTrace(); } in onCreate without being sure the socket really connected so the property s is null

    – MatPag
    Nov 16 '18 at 11:38













  • Another thing is that in onStop method, you need to perform your cleanup actions before calling super.onStop(), so it should be if (mBounded) { unbindService(mConnection); mBounded = false; } super.onStop();

    – MatPag
    Nov 16 '18 at 11:42
















0












0








0








when i press the system back button my app disconnects but i want to return back in this way :




i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);




I think there is an error in my Socket Service cause gaqve me this:



2018-11-16 11:54:45.869 6099-6099/com.app.ifarma I/SocketService: quit:
2018-11-16 11:54:45.871 6099-6099/com.app.ifarma W/System.err: java.net.SocketException: Socket is closed
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at java.net.Socket.getInputStream(Socket.java:930)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.closeConnection(SocketService.java:126)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.sendMessage(SocketService.java:115)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.Scollega$2.run(Scollega.java:71)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.handleCallback(Handler.java:789)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.os.Looper.loop(Looper.java:164)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6541)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
2018-11-16 11:54:45.873 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
2018-11-16 11:54:45.886 6099-6134/com.app.ifarma W/System.err: java.net.SocketException: Socket closed
2018-11-16 11:54:45.886 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead0(Native Method)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead(SocketInputStream.java:114)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:170)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:139)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:288)
2018-11-16 11:54:45.889 6099-6134/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:351)
2018-11-16 11:54:45.894 6099-6134/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
2018-11-16 11:54:45.898 6099-6134/com.app.ifarma W/System.err: at java.io.InputStreamReader.read(InputStreamReader.java:184)
2018-11-16 11:54:45.899 6099-6134/com.app.ifarma W/System.err: at java.io.BufferedReader.fill(BufferedReader.java:172)
2018-11-16 11:54:45.900 6099-6134/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:335)
2018-11-16 11:54:45.905 6099-6134/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:400)
2018-11-16 11:54:45.905 6099-6134/com.app.ifarma W/System.err: at com.app.ifarma.SocketService$ClientThread.run(SocketService.java:272)
2018-11-16 11:54:45.906 6099-6134/com.app.ifarma W/System.err: at java.lang.Thread.run(Thread.java:764)
2018-11-16 11:54:45.907 6099-6131/com.app.ifarma W/System.err: java.net.SocketException: Socket closed
2018-11-16 11:54:45.907 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead0(Native Method)
2018-11-16 11:54:45.908 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead(SocketInputStream.java:114)
2018-11-16 11:54:45.909 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:170)
2018-11-16 11:54:45.909 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:139)
2018-11-16 11:54:45.909 6099-6131/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:288)
2018-11-16 11:54:45.910 6099-6131/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:351)
2018-11-16 11:54:45.918 6099-6131/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
2018-11-16 11:54:45.918 6099-6131/com.app.ifarma W/System.err: at java.io.InputStreamReader.read(InputStreamReader.java:184)
2018-11-16 11:54:45.920 6099-6131/com.app.ifarma W/System.err: at java.io.BufferedReader.fill(BufferedReader.java:172)
2018-11-16 11:54:45.920 6099-6131/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:335)
2018-11-16 11:54:45.921 6099-6131/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:400)
2018-11-16 11:54:45.922 6099-6131/com.app.ifarma W/System.err: at com.app.ifarma.SocketService$ClientThread.run(SocketService.java:272)
2018-11-16 11:54:45.923 6099-6131/com.app.ifarma W/System.err: at java.lang.Thread.run(Thread.java:764)
2018-11-16 11:54:45.977 6099-6099/com.app.ifarma I/SocketService: quit:
2018-11-16 11:54:45.978 6099-6099/com.app.ifarma W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.OutputStream java.net.Socket.getOutputStream()' on a null object reference
2018-11-16 11:54:45.979 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.closeConnection(SocketService.java:125)
2018-11-16 11:54:45.979 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.sendMessage(SocketService.java:115)
2018-11-16 11:54:45.979 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.Scollega$2.run(Scollega.java:71)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.handleCallback(Handler.java:789)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.os.Looper.loop(Looper.java:164)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6541)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
2018-11-16 11:54:45.981 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)


this is my socketService(the problematic part):



@Override
public void onCreate() {
super.onCreate();
}

public void sendMessage(String message) {

line = "";

if (out != null && !out.checkError()) {
out.println(message);
out.flush();
Log.i("SocketService", "" + message.toString());
//ci aspettiamo una risposta solo se non e' quit
if (message.equals("quit:")) {
closeConnection();
}

}
}

public void closeConnection() {

try {
connect = false;
socket.getOutputStream().close();
socket.getInputStream().close();
socket.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}

socket = null;
}


Maybe also my "scollega" class has some problem



public class Scollega extends Activity {

public SocketService s;
//service
boolean mBounded;
ServiceConnection mConnection = new ServiceConnection() {

public void onServiceDisconnected(ComponentName name) {
mBounded = false;
s = null;
}

public void onServiceConnected(ComponentName name, IBinder service) {
mBounded = true;
LocalBinder mLocalBinder = (LocalBinder) service;
s = mLocalBinder.getServerInstance();
}
};

;

@Override
protected void onStart() {
super.onStart();
Intent mIntent = new Intent(this, SocketService.class);
bindService(mIntent, mConnection, BIND_AUTO_CREATE);
}

@Override
protected void onStop() {
super.onStop();
if (mBounded) {
unbindService(mConnection);
mBounded = false;
}
}

;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loader);
getWindow().setWindowAnimations(0);


TextView outputView = (TextView) findViewById(R.id.textLoader);
outputView.setText("Scollegamento...");

//creiamo il timeout dopo l'avvio del servizio
Handler handler = new Handler();
handler.postDelayed(new Runnable() {

@Override
public void run() {

try {
s.sendMessage("quit:");
} catch (Exception e) {
e.printStackTrace();
}


//torniamo in Home
Intent i = new Intent(Scollega.this, Home.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(i);
overridePendingTransition(R.anim.slide_left, R.anim.slide_right);
finish();
}
}, 1000); // ritardiamo l'esecuzione di un secondo

}


I inherited this program from a person who no longer wants to deal with it, I solved most of the problems but I do not know how to do this part...










share|improve this question
















when i press the system back button my app disconnects but i want to return back in this way :




i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);




I think there is an error in my Socket Service cause gaqve me this:



2018-11-16 11:54:45.869 6099-6099/com.app.ifarma I/SocketService: quit:
2018-11-16 11:54:45.871 6099-6099/com.app.ifarma W/System.err: java.net.SocketException: Socket is closed
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at java.net.Socket.getInputStream(Socket.java:930)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.closeConnection(SocketService.java:126)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.sendMessage(SocketService.java:115)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.Scollega$2.run(Scollega.java:71)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.handleCallback(Handler.java:789)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.os.Looper.loop(Looper.java:164)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6541)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2018-11-16 11:54:45.872 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
2018-11-16 11:54:45.873 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
2018-11-16 11:54:45.886 6099-6134/com.app.ifarma W/System.err: java.net.SocketException: Socket closed
2018-11-16 11:54:45.886 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead0(Native Method)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead(SocketInputStream.java:114)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:170)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:139)
2018-11-16 11:54:45.887 6099-6134/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:288)
2018-11-16 11:54:45.889 6099-6134/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:351)
2018-11-16 11:54:45.894 6099-6134/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
2018-11-16 11:54:45.898 6099-6134/com.app.ifarma W/System.err: at java.io.InputStreamReader.read(InputStreamReader.java:184)
2018-11-16 11:54:45.899 6099-6134/com.app.ifarma W/System.err: at java.io.BufferedReader.fill(BufferedReader.java:172)
2018-11-16 11:54:45.900 6099-6134/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:335)
2018-11-16 11:54:45.905 6099-6134/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:400)
2018-11-16 11:54:45.905 6099-6134/com.app.ifarma W/System.err: at com.app.ifarma.SocketService$ClientThread.run(SocketService.java:272)
2018-11-16 11:54:45.906 6099-6134/com.app.ifarma W/System.err: at java.lang.Thread.run(Thread.java:764)
2018-11-16 11:54:45.907 6099-6131/com.app.ifarma W/System.err: java.net.SocketException: Socket closed
2018-11-16 11:54:45.907 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead0(Native Method)
2018-11-16 11:54:45.908 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.socketRead(SocketInputStream.java:114)
2018-11-16 11:54:45.909 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:170)
2018-11-16 11:54:45.909 6099-6131/com.app.ifarma W/System.err: at java.net.SocketInputStream.read(SocketInputStream.java:139)
2018-11-16 11:54:45.909 6099-6131/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:288)
2018-11-16 11:54:45.910 6099-6131/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:351)
2018-11-16 11:54:45.918 6099-6131/com.app.ifarma W/System.err: at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
2018-11-16 11:54:45.918 6099-6131/com.app.ifarma W/System.err: at java.io.InputStreamReader.read(InputStreamReader.java:184)
2018-11-16 11:54:45.920 6099-6131/com.app.ifarma W/System.err: at java.io.BufferedReader.fill(BufferedReader.java:172)
2018-11-16 11:54:45.920 6099-6131/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:335)
2018-11-16 11:54:45.921 6099-6131/com.app.ifarma W/System.err: at java.io.BufferedReader.readLine(BufferedReader.java:400)
2018-11-16 11:54:45.922 6099-6131/com.app.ifarma W/System.err: at com.app.ifarma.SocketService$ClientThread.run(SocketService.java:272)
2018-11-16 11:54:45.923 6099-6131/com.app.ifarma W/System.err: at java.lang.Thread.run(Thread.java:764)
2018-11-16 11:54:45.977 6099-6099/com.app.ifarma I/SocketService: quit:
2018-11-16 11:54:45.978 6099-6099/com.app.ifarma W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.OutputStream java.net.Socket.getOutputStream()' on a null object reference
2018-11-16 11:54:45.979 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.closeConnection(SocketService.java:125)
2018-11-16 11:54:45.979 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.SocketService.sendMessage(SocketService.java:115)
2018-11-16 11:54:45.979 6099-6099/com.app.ifarma W/System.err: at com.app.ifarma.Scollega$2.run(Scollega.java:71)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.handleCallback(Handler.java:789)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.os.Looper.loop(Looper.java:164)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6541)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2018-11-16 11:54:45.980 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
2018-11-16 11:54:45.981 6099-6099/com.app.ifarma W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)


this is my socketService(the problematic part):



@Override
public void onCreate() {
super.onCreate();
}

public void sendMessage(String message) {

line = "";

if (out != null && !out.checkError()) {
out.println(message);
out.flush();
Log.i("SocketService", "" + message.toString());
//ci aspettiamo una risposta solo se non e' quit
if (message.equals("quit:")) {
closeConnection();
}

}
}

public void closeConnection() {

try {
connect = false;
socket.getOutputStream().close();
socket.getInputStream().close();
socket.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}

socket = null;
}


Maybe also my "scollega" class has some problem



public class Scollega extends Activity {

public SocketService s;
//service
boolean mBounded;
ServiceConnection mConnection = new ServiceConnection() {

public void onServiceDisconnected(ComponentName name) {
mBounded = false;
s = null;
}

public void onServiceConnected(ComponentName name, IBinder service) {
mBounded = true;
LocalBinder mLocalBinder = (LocalBinder) service;
s = mLocalBinder.getServerInstance();
}
};

;

@Override
protected void onStart() {
super.onStart();
Intent mIntent = new Intent(this, SocketService.class);
bindService(mIntent, mConnection, BIND_AUTO_CREATE);
}

@Override
protected void onStop() {
super.onStop();
if (mBounded) {
unbindService(mConnection);
mBounded = false;
}
}

;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loader);
getWindow().setWindowAnimations(0);


TextView outputView = (TextView) findViewById(R.id.textLoader);
outputView.setText("Scollegamento...");

//creiamo il timeout dopo l'avvio del servizio
Handler handler = new Handler();
handler.postDelayed(new Runnable() {

@Override
public void run() {

try {
s.sendMessage("quit:");
} catch (Exception e) {
e.printStackTrace();
}


//torniamo in Home
Intent i = new Intent(Scollega.this, Home.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(i);
overridePendingTransition(R.anim.slide_left, R.anim.slide_right);
finish();
}
}, 1000); // ritardiamo l'esecuzione di un secondo

}


I inherited this program from a person who no longer wants to deal with it, I solved most of the problems but I do not know how to do this part...







java android sockets






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 11:37









Michael

21.5k83572




21.5k83572










asked Nov 16 '18 at 11:31









ioana chiperiioana chiperi

12




12













  • please, post all service code.

    – Augusto
    Nov 16 '18 at 11:36











  • Using flag clear top If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

    – Piyush
    Nov 16 '18 at 11:37











  • One of the exception you are getting is because you are calling try { s.sendMessage("quit:"); } catch (Exception e) { e.printStackTrace(); } in onCreate without being sure the socket really connected so the property s is null

    – MatPag
    Nov 16 '18 at 11:38













  • Another thing is that in onStop method, you need to perform your cleanup actions before calling super.onStop(), so it should be if (mBounded) { unbindService(mConnection); mBounded = false; } super.onStop();

    – MatPag
    Nov 16 '18 at 11:42





















  • please, post all service code.

    – Augusto
    Nov 16 '18 at 11:36











  • Using flag clear top If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

    – Piyush
    Nov 16 '18 at 11:37











  • One of the exception you are getting is because you are calling try { s.sendMessage("quit:"); } catch (Exception e) { e.printStackTrace(); } in onCreate without being sure the socket really connected so the property s is null

    – MatPag
    Nov 16 '18 at 11:38













  • Another thing is that in onStop method, you need to perform your cleanup actions before calling super.onStop(), so it should be if (mBounded) { unbindService(mConnection); mBounded = false; } super.onStop();

    – MatPag
    Nov 16 '18 at 11:42



















please, post all service code.

– Augusto
Nov 16 '18 at 11:36





please, post all service code.

– Augusto
Nov 16 '18 at 11:36













Using flag clear top If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

– Piyush
Nov 16 '18 at 11:37





Using flag clear top If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

– Piyush
Nov 16 '18 at 11:37













One of the exception you are getting is because you are calling try { s.sendMessage("quit:"); } catch (Exception e) { e.printStackTrace(); } in onCreate without being sure the socket really connected so the property s is null

– MatPag
Nov 16 '18 at 11:38







One of the exception you are getting is because you are calling try { s.sendMessage("quit:"); } catch (Exception e) { e.printStackTrace(); } in onCreate without being sure the socket really connected so the property s is null

– MatPag
Nov 16 '18 at 11:38















Another thing is that in onStop method, you need to perform your cleanup actions before calling super.onStop(), so it should be if (mBounded) { unbindService(mConnection); mBounded = false; } super.onStop();

– MatPag
Nov 16 '18 at 11:42







Another thing is that in onStop method, you need to perform your cleanup actions before calling super.onStop(), so it should be if (mBounded) { unbindService(mConnection); mBounded = false; } super.onStop();

– MatPag
Nov 16 '18 at 11:42














0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337008%2fsocket-service-onbackpressed%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337008%2fsocket-service-onbackpressed%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine