Как обновить временную шкалу в приложении Twitter в Android - PullRequest
0 голосов
/ 12 октября 2011
public void onServiceConnected(ComponentName name, IBinder service) {
            Log.i( "Service connection established","");

            // that's how we get the client side of the IPC connection
            api = com.oreilly.android.otweet.TweetCollectorApi.Stub.asInterface(service);
            try {
                api.addListener(collectorListener);
            /*  Intent i = new Intent(StatusListActivity.this, StatusListActivity.class);
                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(i);*/
            } catch (RemoteException e) {
                Log.e("", "Failed to add listener", e);
            }

1 Ответ

0 голосов
/ 12 октября 2011

Чтобы остановить сервис при остановке приложения, нам нужно позвонить unbindService() в onDestroy().

Edit:

В вашей ссылке есть код для этого

@Override
            protected void onDestroy() {
              super.onDestroy();

              try {
                api.removeListener(collectorListener);
                unbindService(serviceConnection);
              } catch (Throwable t) {
                // catch any issues, typical for destroy routines
                // even if we failed to destroy something, we need to continue destroying
                Log.w(TAG, "Failed to unbind from the service", t);
              }

              Log.i(TAG, "Activity destroyed");
            }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...