ServiceConnection.onServiceConnected() never called after binding to started service

后端 未结 3 1913
渐次进展
渐次进展 2021-01-06 18:25

In a game application I have the following scenario:

  • From the main game Activity, the player starts several game tasks that run in the background
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-06 18:47

    You have to return your Binder inner class from

    private final IBinder mBinder = new ServiceBinder();
    
     public class ServiceBinder extends Binder {
       public PlayerActivity getService() {
       return PlayerActivity.this;
         }
      }
    
    @Nullable
    @Override
               public IBinder onBind(Intent intent) {
                 return mBinder;
               }
    

提交回复
热议问题