Issue
I find out about this problem for my users with the new Wear OS 3. I am trying to forbid to OS from detecting the Top swipe gesture for showing the "System Quick settings panel". Until now in Wear OS 2- devices, it's not allowed to open this system shortcut settings Panel into a custom app.
"System Quick settings panel":
I currently detect swipe from the top gesture (via NavigationDrawer) and show the 'logging out' fragment.
private void initNavigationDrawer() {
List<NavigationItem> navigationItems = new ArrayList<>();
navigationItems.add(new NavigationItem(getString(R.string.logout_button), getDrawable(R.drawable.ic_bsh_play_icon)));
binding.navigationDrawer.setAdapter(new NavigationAdapter(navigationItems));
binding.navigationDrawer.getController().peekDrawer();
binding.navigationDrawer.addOnItemSelectedListener(pos -> {
if (navigationItems.get(pos).getItemTitle().equals(getString(R.string.logout_button))) {
mainViewModel.logout();
}
});
}
NavigationAdapter:
public class NavigationAdapter extends WearableNavigationDrawerView.WearableNavigationDrawerAdapter {
private final List<NavigationItem> items;
NavigationAdapter(List<NavigationItem> items) {
this.items = items;
}
@Override
public CharSequence getItemText(int pos) {
return items.get(pos).getItemTitle();
}
@Override
public Drawable getItemDrawable(int pos) {
return items.get(pos).getItemIcon();
}
@Override
public int getCount() {
return items.size();
}
}
Thank you in advance!!
P.C I found one similar question, with some guidelines here
Solution
You can try "Lock task mode" described here. I don't know if this solution meets your requirements, but for my application it was enough to change the AndroidManifest.xml. For your activity, add the line android:lockTaskMode with the value "always". For example:
...
<activity
android:name=".MainActivity"
android:exported="true"
android:lockTaskMode="always"
android:configChanges="orientation|keyboardHidden"
android:theme="@style/YourTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
Add your style based on the existing one. Here is my added style file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="YourTheme" parent="@style/Theme.AppCompat">
<item name="android:windowSwipeToDismiss">false</item>
</style>
</resources>
You can also provide an exit from your application by intercepting button presses on the device body, or by adding a button on the user interface.
Answered By - Denis Prilutsky
Answer Checked By - Mary Flores (JavaFixing Volunteer)