Example usage for android.content Intent addCategory

List of usage examples for android.content Intent addCategory

Introduction

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

Prototype

public @NonNull Intent addCategory(String category) 

Source Link

Document

Add a new category to the intent.

Usage

From source file:com.cognizant.trumobi.PersonaLauncher.java

/**
 * ADW: Home binding actions/* ww  w .ja  v a  2  s. c om*/
 */
public void fireHomeBinding(int bindingValue, int type) {
    // ADW: switch home button binding user selection
    if (mIsEditMode || mIsWidgetEditMode)
        return;
    switch (bindingValue) {
    case BIND_DEFAULT:
        dismissPreviews();
        if (!mWorkspace.isDefaultScreenShowing()) {
            mWorkspace.moveToDefaultScreen();
        }
        break;
    case BIND_HOME_PREVIEWS:
        if (!mWorkspace.isDefaultScreenShowing()) {
            dismissPreviews();
            mWorkspace.moveToDefaultScreen();
        } else {
            if (!showingPreviews) {
                showPreviews(mHandleView, 0, mWorkspace.mHomeScreens);
            } else {
                dismissPreviews();
            }
        }
        break;
    case BIND_PREVIEWS:
        if (!showingPreviews) {
            showPreviews(mHandleView, 0, mWorkspace.mHomeScreens);
        } else {
            dismissPreviews();
        }
        break;
    case BIND_APPS:
        dismissPreviews();
        if (isAllAppsVisible()) {
            mRAB.setVisibility(View.VISIBLE);
            mLAB.setVisibility(View.VISIBLE);
            mHandleView.updateIcon();
            closeDrawer();
        } else {
            showAllApps(true, null);

        }
        break;
    case BIND_STATUSBAR:
        WindowManager.LayoutParams attrs = getWindow().getAttributes();
        /*
         * if((attrs.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) ==
         * WindowManager.LayoutParams.FLAG_FULLSCREEN){ //go non-full screen
         * fullScreen(false); }else{ //go full screen fullScreen(true); }
         */
        // 290778 commented for Non full screen mode
        fullScreen(false);
        break;
    case BIND_NOTIFICATIONS:
        dismissPreviews();
        showNotifications();
        break;
    case BIND_HOME_NOTIFICATIONS:
        if (!mWorkspace.isDefaultScreenShowing()) {
            dismissPreviews();
            mWorkspace.moveToDefaultScreen();
        } else {
            dismissPreviews();
            showNotifications();
        }
        break;
    case BIND_DOCKBAR:
        dismissPreviews();
        if (showDockBar) {
            if (mDockBar.isOpen()) {
                mDockBar.close();
            } else {
                mDockBar.open();
            }
        }
        break;
    case BIND_APP_LAUNCHER:
        // Launch or bring to front selected app
        // Get PackageName and ClassName of selected App
        String package_name = "";
        String name = "";
        switch (type) {
        case 1:
            package_name = PersonaAlmostNexusSettingsHelper.getHomeBindingAppToLaunchPackageName(this);
            name = PersonaAlmostNexusSettingsHelper.getHomeBindingAppToLaunchName(this);
            break;
        case 2:
            package_name = PersonaAlmostNexusSettingsHelper.getSwipeUpAppToLaunchPackageName(this);
            name = PersonaAlmostNexusSettingsHelper.getSwipeUpAppToLaunchName(this);
            break;
        case 3:
            package_name = PersonaAlmostNexusSettingsHelper.getSwipeDownAppToLaunchPackageName(this);
            name = PersonaAlmostNexusSettingsHelper.getSwipeDownAppToLaunchName(this);
            break;
        default:
            break;
        }
        // Create Intent to Launch App
        if (package_name != "" && name != "") {
            Intent i = new Intent();
            i.setAction(Intent.ACTION_MAIN);
            i.addCategory(Intent.CATEGORY_LAUNCHER);
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
            i.setComponent(new ComponentName(package_name, name));
            try {
                startActivity(i);
            } catch (Exception e) {
            }
        }
        break;
    default:
        break;
    }
}

From source file:com.bernard.beaconportal.activities.activity.MessageList.java

void onImport() {
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("*/*");

    PackageManager packageManager = getPackageManager();
    List<ResolveInfo> infos = packageManager.queryIntentActivities(i, 0);

    if (infos.size() > 0) {
        startActivityForResult(Intent.createChooser(i, null), ACTIVITY_REQUEST_PICK_SETTINGS_FILE);
    } else {//w  ww.  j a  v  a 2 s  . c  o  m
        showDialog(DIALOG_NO_FILE_MANAGER);
    }
}

From source file:com.irccloud.android.activity.MainActivity.java

private void insertPhoto() {
    if (buffer == null)
        return;/*from w  w w  . ja  va2s  .  co m*/

    AlertDialog.Builder builder;
    AlertDialog dialog;
    builder = new AlertDialog.Builder(this);
    builder.setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB);
    String[] items = (Build.VERSION.SDK_INT < 19 || !NetworkConnection.getInstance().uploadsAvailable())
            ? new String[] { "Take a Photo", "Choose Existing", "Start a Pastebin", "Pastebins" }
            : new String[] { "Take a Photo", "Choose Existing Photo", "Choose Existing Document",
                    "Start a Pastebin", "Pastebins" };
    if (NetworkConnection.getInstance().uploadsAvailable()) {
        items = Arrays.copyOf(items, items.length + 1);
        items[items.length - 1] = "File Uploads";
    }

    final String[] dialogItems = items;

    builder.setItems(dialogItems, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent i;
            if (buffer != null) {
                switch (dialogItems[which]) {
                case "Take a Photo":
                    try {
                        File imageDir = new File(Environment.getExternalStorageDirectory(), "IRCCloud");
                        imageDir.mkdirs();
                        new File(imageDir, ".nomedia").createNewFile();
                        imageCaptureURI = Uri
                                .fromFile(File.createTempFile("irccloudcapture", ".jpg", imageDir));
                        i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                        i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageCaptureURI);
                        startActivityForResult(i, REQUEST_CAMERA);
                    } catch (IOException e) {
                    }
                    break;
                case "Choose Existing":
                case "Choose Existing Photo":
                    i = new Intent(Intent.ACTION_GET_CONTENT,
                            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                    i.addCategory(Intent.CATEGORY_OPENABLE);
                    i.setType("image/*");
                    startActivityForResult(Intent.createChooser(i, "Select Picture"), REQUEST_PHOTO);
                    break;
                case "Choose Existing Document":
                    i = new Intent(Intent.ACTION_GET_CONTENT);
                    i.addCategory(Intent.CATEGORY_OPENABLE);
                    i.setType("*/*");
                    startActivityForResult(Intent.createChooser(i, "Select A Document"), REQUEST_DOCUMENT);
                    break;
                case "Start a Pastebin":
                    show_pastebin_prompt();
                    break;
                case "Pastebins":
                    i = new Intent(MainActivity.this, PastebinsActivity.class);
                    startActivity(i);
                    break;
                case "File Uploads":
                    i = new Intent(MainActivity.this, UploadsActivity.class);
                    i.putExtra("cid", buffer.cid);
                    i.putExtra("to", buffer.name);
                    i.putExtra("msg", messageTxt.getText().toString());
                    startActivityForResult(i, REQUEST_UPLOADS);
                    break;
                }
            }
            dialog.dismiss();
        }
    });
    dialog = builder.create();
    dialog.setOwnerActivity(MainActivity.this);
    dialog.show();
}

From source file:org.getlantern.firetweet.util.Utils.java

public static boolean handleMenuItemClick(Context context, Fragment fragment, FragmentManager fm,
        AsyncTwitterWrapper twitter, ParcelableStatus status, MenuItem item) {
    switch (item.getItemId()) {
    case MENU_COPY: {
        if (ClipboardUtils.setText(context, status.text_plain)) {
            showOkMessage(context, R.string.text_copied, false);
        }/*www .  ja va 2  s  . com*/
        break;
    }
    case MENU_RETWEET: {
        if (isMyRetweet(status)) {
            twitter.cancelRetweetAsync(status.account_id, status.id, status.my_retweet_id);
        } else {
            twitter.retweetStatusAsync(status.account_id, status.id);
        }
        break;
    }
    case MENU_QUOTE: {
        final Intent intent = new Intent(INTENT_ACTION_QUOTE);
        intent.putExtra(EXTRA_STATUS, status);
        context.startActivity(intent);
        break;
    }
    case MENU_REPLY: {
        final Intent intent = new Intent(INTENT_ACTION_REPLY);
        intent.putExtra(EXTRA_STATUS, status);
        context.startActivity(intent);
        break;
    }
    case MENU_FAVORITE: {
        if (status.is_favorite) {
            twitter.destroyFavoriteAsync(status.account_id, status.id);
        } else {
            twitter.createFavoriteAsync(status.account_id, status.id);
        }
        break;
    }
    case MENU_DELETE: {
        DestroyStatusDialogFragment.show(fm, status);
        break;
    }
    case MENU_ADD_TO_FILTER: {
        AddStatusFilterDialogFragment.show(fm, status);
        break;
    }
    case MENU_SET_COLOR: {
        final Intent intent = new Intent(context, ColorPickerDialogActivity.class);
        final int color = getUserColor(context, status.user_id, true);
        if (color != 0) {
            intent.putExtra(EXTRA_COLOR, color);
        }
        intent.putExtra(EXTRA_CLEAR_BUTTON, color != 0);
        intent.putExtra(EXTRA_ALPHA_SLIDER, false);
        if (fragment != null) {
            fragment.startActivityForResult(intent, REQUEST_SET_COLOR);
        } else if (context instanceof Activity) {
            ((Activity) context).startActivityForResult(intent, REQUEST_SET_COLOR);
        }
        break;
    }
    case MENU_CLEAR_NICKNAME: {
        clearUserNickname(context, status.user_id);
        break;
    }
    case MENU_SET_NICKNAME: {
        final String nick = getUserNickname(context, status.user_id, true);
        SetUserNicknameDialogFragment.show(fm, status.user_id, nick);
        break;
    }
    case MENU_TRANSLATE: {
        final ParcelableCredentials account = ParcelableAccount.getCredentials(context, status.account_id);
        if (isOfficialCredentials(context, account)) {
            StatusTranslateDialogFragment.show(fm, status);
        } else {
            final Resources resources = context.getResources();
            final Locale locale = resources.getConfiguration().locale;
            try {
                final String template = "http://translate.google.com/#%s|%s|%s";
                final String sourceLang = "auto";
                final String targetLang = URLEncoder.encode(locale.getLanguage(), HTTP.UTF_8);
                final String text = URLEncoder.encode(status.text_unescaped, HTTP.UTF_8);
                final Uri uri = Uri.parse(String.format(Locale.ROOT, template, sourceLang, targetLang, text));
                final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                intent.addCategory(Intent.CATEGORY_BROWSABLE);
                context.startActivity(intent);
            } catch (UnsupportedEncodingException ignore) {

            }
        }
        break;
    }
    case MENU_OPEN_WITH_ACCOUNT: {
        final Intent intent = new Intent(INTENT_ACTION_SELECT_ACCOUNT);
        intent.setClass(context, AccountSelectorActivity.class);
        intent.putExtra(EXTRA_SINGLE_SELECTION, true);
        if (fragment != null) {
            fragment.startActivityForResult(intent, REQUEST_SELECT_ACCOUNT);
        } else if (context instanceof Activity) {
            ((Activity) context).startActivityForResult(intent, REQUEST_SELECT_ACCOUNT);
        }
        break;
    }
    default: {
        if (item.getIntent() != null) {
            try {
                context.startActivity(item.getIntent());
            } catch (final ActivityNotFoundException e) {
                Crashlytics.logException(e);
                Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return true;
}

From source file:com.codename1.impl.android.AndroidImplementation.java

@Override
public boolean minimizeApplication() {
    Intent startMain = new Intent(Intent.ACTION_MAIN);
    startMain.addCategory(Intent.CATEGORY_HOME);
    startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startMain.putExtra("WaitForResult", Boolean.FALSE);
    getContext().startActivity(startMain);
    return true;/*from w  w  w . j a  v a  2 s  .com*/
}

From source file:com.codename1.impl.android.AndroidImplementation.java

@Override
public void restoreMinimizedApplication() {
    if (getActivity() != null) {
        Intent i = new Intent(getActivity(), getActivity().getClass());
        i.setAction(Intent.ACTION_MAIN);
        i.addCategory(Intent.CATEGORY_LAUNCHER);
        getContext().startActivity(i);/*from   w  w w .j  ava  2  s  .c o m*/
    }
}

From source file:com.codename1.impl.android.AndroidImplementation.java

public void openGallery(final ActionListener response, int type) {
    if (!isGalleryTypeSupported(type)) {
        throw new IllegalArgumentException("Gallery type " + type + " not supported on this platform.");
    }//from   w w  w .j a  va2 s .c  o m
    if (getActivity() == null) {
        throw new RuntimeException("Cannot open galery in background mode");
    }
    if (!checkForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE,
            "This is required to browse the photos")) {
        return;
    }
    if (editInProgress()) {
        stopEditing(true);
    }
    final boolean multi;
    switch (type) {
    case Display.GALLERY_ALL_MULTI:
        multi = true;
        type = Display.GALLERY_ALL;
        break;
    case Display.GALLERY_VIDEO_MULTI:
        multi = true;
        type = Display.GALLERY_VIDEO;
        break;
    case Display.GALLERY_IMAGE_MULTI:
        multi = true;
        type = Display.GALLERY_IMAGE;
        break;
    case -9998:
        multi = true;
        type = -9999;
        break;
    default:
        multi = false;
    }

    callback = new EventDispatcher();
    callback.addListener(response);
    Intent galleryIntent = new Intent(Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
    if (multi) {
        galleryIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
    }
    if (type == Display.GALLERY_VIDEO) {
        galleryIntent.setType("video/*");
    } else if (type == Display.GALLERY_IMAGE) {
        galleryIntent.setType("image/*");
    } else if (type == Display.GALLERY_ALL) {
        galleryIntent.setType("image/* video/*");
    } else if (type == -9999) {
        galleryIntent = new Intent();
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
            galleryIntent.setAction(Intent.ACTION_OPEN_DOCUMENT);
        } else {
            galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
        }
        galleryIntent.addCategory(Intent.CATEGORY_OPENABLE);

        // set MIME type for image
        galleryIntent.setType("*/*");
        galleryIntent.putExtra(Intent.EXTRA_MIME_TYPES,
                Display.getInstance().getProperty("android.openGallery.accept", "*/*").split(","));
    } else {
        galleryIntent.setType("*/*");
    }
    this.getActivity().startActivityForResult(galleryIntent, multi ? OPEN_GALLERY_MULTI : OPEN_GALLERY);
}