Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. Intent intent = new Intent(SplashActivity.this, TCPConnectionService.class);
  2. startForegroundService(intent);
  3.  
  4. } else {
  5.  
  6. Intent intent = new Intent(SplashActivity.this, TCPConnectionService.class);
  7. startService(intent);
  8.  
  9. }
  10.  
  11. private ServiceConnection mConnection = new ServiceConnection() {
  12. //EDITED PART
  13. @Override
  14. public void onServiceConnected(ComponentName name, IBinder service) {
  15. mBoundService = ((TCPConnectionService.LocalBinder) service).getService();
  16.  
  17. mIsBound = true;
  18.  
  19. Log.e("SERVICE CONNECTED>>>>", "yes");
  20.  
  21. }
  22.  
  23. @Override
  24. public void onServiceDisconnected(ComponentName name) {
  25. mBoundService = null;
  26. }
  27.  
  28. };
  29.  
  30. @Override
  31. protected void onCreate(Bundle savedInstanceState) {
  32. super.onCreate(savedInstanceState);
  33. setContentView(R.layout.activity_settings);
  34.  
  35. Log.e("SERVICE CONNECTED 222>>", "yes");
  36. doBindService();
  37. sendAuthenticate();
  38.  
  39. }
  40.  
  41. private void doBindService() {
  42. getApplicationContext().bindService(new Intent(getApplicationContext(), TCPConnectionService.class), mConnection, Context.BIND_AUTO_CREATE);
  43. if (mBoundService != null) {
  44. mBoundService.IsBoundable();
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement