开发者

How to refresh timeline in twitter app in android

开发者 https://www.devze.com 2023-04-12 16:33 出处:网络
public void onServiceConnected(ComponentName name, IBinder service) { Log.i( \"Service connection established\",\"\");
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);
            }


To stop service when application stops we need to call unbindService() in the onDestroy().

Edit:

In your link there are code for this

@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");
            }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号