0
我有两个活动。 如果我需要将Activity 1的启动服务的意图分享给Activity 2以停止服务(因为onStartCommand()返回START_STICKY因此需要使用相同的意图停止服务)。我该如何巧妙地去解决它。在两个活动之间共享实例对象的好方法是什么?
在活动1
Intent wrapperServiceIntent = new Intent(mContext,BleWrapperService.class);
bindService(wrapperServiceIntent,mBLEWrapperServiceConnection,BIND_AUTO_CREATE);
startService(wrapperServiceIntent);
在活动2
我需要启动该服务(即wrapperServiceIntent)意图
stopService(wrapperServiceIntent);
mContext.unbindService(mServiceConnection);
向我们显示您的代码。 – dsharew
//通过: intent.putExtra(“MyClass”,obj); //检索第二个对象的活动 getIntent()。getSerializableExtra(“MyClass”); – Drim
@DegenSharew。检查代码 –