Skip to content

Instantly share code, notes, and snippets.

@PomepuyN
Last active August 29, 2015 14:06
Show Gist options
  • Save PomepuyN/7b29e2592d39d687e95a to your computer and use it in GitHub Desktop.
Save PomepuyN/7b29e2592d39d687e95a to your computer and use it in GitHub Desktop.
Request Wear Mini Launcher to be disabled on your app

As Wear Mini launcher constantly retain a zone of the screen from being touched, it may cause issue with your app. Here is how you can disable it when your app is running.

Manifest

Add this line to your Manifest. Wear Mini Launcher will retrieve this meta to put your app in the exclusion list by default (the user will be able to revert this setting).

<manifest>

    <application>
        <meta-data android:name="default-block-wml" android:value="true" />
        ...
    </application>

</manifest>

Activity

If an app is in the exclusion list, the drawer will stop when the app is launched by the launcher and will be restarted when the watch enter the dim mode. To refine this behavior, you can explicitly request the launcher to be closed and re-launched.

public class MainActivity extends Activity {

    ...

    @Override
    protected void onResume() {
        Intent i = new Intent();
        i.setAction("com.npi.wearminilauncher.APPLAUNCHED");
        i.putExtra("package", getPackageName());
        i.putExtra("activity", MainActivity.class.getName());
        sendBroadcast(i);
        super.onResume();
    }

    @Override
    protected void onPause() {
        Intent i = new Intent();
        i.setAction("com.npi.wearminilauncher.APPCLOSED");
        i.putExtra("package", getPackageName());
        i.putExtra("activity", MainActivity.class.getName());
        sendBroadcast(i);
        super.onPause();
    }
}

Be careful though, this will work only if your Activity is launchable. If you have multiple activities in your workflow, please use the launchable activity getName(). To be launchable an activity has to have this category in the manifest:

<category android:name="android.intent.category.LAUNCHER" />

Test your implementation

You can activate a debug mode in Wear Mini Launcher. To do so, tap 7 times on the top of the list of the watch app and enable the debug mode.

alt text

alt text

alt text

alt text

You can now see the drawer handles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment