Example usage for android.content Intent CATEGORY_APP_MAPS

List of usage examples for android.content Intent CATEGORY_APP_MAPS

Introduction

In this page you can find the example usage for android.content Intent CATEGORY_APP_MAPS.

Prototype

String CATEGORY_APP_MAPS

To view the source code for android.content Intent CATEGORY_APP_MAPS.

Click Source Link

Document

Used with #ACTION_MAIN to launch the maps application.

Usage

From source file:com.farmerbb.taskbar.activity.KeyboardShortcutActivity.java

@SuppressWarnings("deprecation")
@Override//  w ww  .ja v  a2 s  .  c  o m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Perform different actions depending on how this activity was launched
    switch (getIntent().getAction()) {
    case Intent.ACTION_MAIN:
        Intent selector = getIntent().getSelector();
        Set<String> categories = selector != null ? selector.getCategories() : getIntent().getCategories();

        if (categories.contains(Intent.CATEGORY_APP_MAPS)) {
            SharedPreferences pref = U.getSharedPreferences(this);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && pref.getBoolean("freeform_hack", false)
                    && isInMultiWindowMode() && !FreeformHackHelper.getInstance().isFreeformHackActive()) {
                U.startFreeformHack(this, false, false);
            }

            Intent startStopIntent;

            if (pref.getBoolean("taskbar_active", false))
                startStopIntent = new Intent("com.farmerbb.taskbar.QUIT");
            else
                startStopIntent = new Intent("com.farmerbb.taskbar.START");

            startStopIntent.setPackage(BuildConfig.APPLICATION_ID);
            sendBroadcast(startStopIntent);
        } else if (categories.contains(Intent.CATEGORY_APP_CALENDAR))
            U.lockDevice(this);

        break;
    case Intent.ACTION_ASSIST:
        if (U.isServiceRunning(this, StartMenuService.class)) {
            LocalBroadcastManager.getInstance(this)
                    .sendBroadcast(new Intent("com.farmerbb.taskbar.TOGGLE_START_MENU"));
        } else {
            Intent intent = new Intent("com.google.android.googlequicksearchbox.TEXT_ASSIST");
            if (intent.resolveActivity(getPackageManager()) == null)
                intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);

            if (intent.resolveActivity(getPackageManager()) != null) {
                SharedPreferences pref = U.getSharedPreferences(this);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && pref.getBoolean("freeform_hack", false)
                        && isInMultiWindowMode()) {
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
                    U.launchAppMaximized(getApplicationContext(), intent);
                } else {
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(intent);
                }
            }
        }
        break;
    }

    finish();
}