I have two Activity classes. Activity A and Activity B. Later on I added Activity C which gets launched when user shakes the device be
Create a main activity class which will be extended by Activity A, B and C.
You can register your ShakeListener in this main activity.
You can define your own ActivityStack in Application class, properly manage by adding and removing activities. Finally refer to this stack from activity C.
There is example how ActivityStack works: Back Stack Example
In your case, you need to implement a Service to listen to sensors in the background. Go through documentation:Service
You cannot just use Broadcastreceiver to accomplish this task.
Reference:
Android sensor listening when app in background
Refer this link for help: http://code.tutsplus.com/tutorials/android-barometer-logger-acquiring-sensor-data--mobile-10558