0

I have an activity (extends WearableActivity) inside which there are multiple fragments.I want only one of the fragment to be in "always on" mode.The default functionality of "closing current app" should happen on ambient timeout for other fragments.How can I achieve this?

Learner_Programmer
  • 1,259
  • 1
  • 13
  • 38

1 Answers1

0

You can detect when your app has entered ambient mode by implementing an onEnterAmbient event handler:

@Override
public void onEnterAmbient(Bundle ambientDetails) {
    super.onEnterAmbient(ambientDetails);

    // your code here
}

From your question, I'm assuming you've already implemented the other pieces required to support ambient mode, as documented at http://developer.android.com/training/wearables/apps/always-on.html.

Within that event handler, you'll just hide all but your "always on" fragment - probably with FragmentTransaction.remove(), but the exact technique will depend on your implementation, and it should be no different than hiding a fragment anywhere else in your apps.

Sterling
  • 6,365
  • 2
  • 32
  • 40