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.doomy.decode.ScanActivity.java

private void openAboutDialog() {
    LayoutInflater mLayoutInflater = LayoutInflater.from(ScanActivity.this);
    View mView = mLayoutInflater.inflate(R.layout.view_about, null);

    ImageView mImageViewMrDoomy = (ImageView) mView.findViewById(R.id.imageViewMrDoomy);
    ImageView mImageViewStudio = (ImageView) mView.findViewById(R.id.imageViewStudio);
    ImageView mImageViewGitHub = (ImageView) mView.findViewById(R.id.imageViewGitHub);
    Drawable mMrDoomy = mImageViewMrDoomy.getDrawable();
    Drawable mStudio = mImageViewStudio.getDrawable();
    Drawable mGitHub = mImageViewGitHub.getDrawable();
    mMrDoomy.setColorFilter(getResources().getColor(R.color.greenDark), PorterDuff.Mode.SRC_ATOP);
    mStudio.setColorFilter(getResources().getColor(R.color.green), PorterDuff.Mode.SRC_ATOP);
    mGitHub.setColorFilter(getResources().getColor(R.color.greyMaterialDark), PorterDuff.Mode.SRC_ATOP);

    mImageViewGitHub.setOnClickListener(new View.OnClickListener() {
        @Override/*from w  w  w.  j  ava2 s .  c om*/
        public void onClick(View v) {
            Intent mIntent = new Intent();
            mIntent.setAction(Intent.ACTION_VIEW);
            mIntent.addCategory(Intent.CATEGORY_BROWSABLE);
            mIntent.setData(Uri.parse(getString(R.string.url)));
            startActivity(mIntent);
        }
    });

    AlertDialog.Builder mAlertDialog = new AlertDialog.Builder(ScanActivity.this, Utils.setThemeDialog());

    mAlertDialog.setTitle(getString(R.string.about));
    mAlertDialog.setView(mView);
    mAlertDialog.setPositiveButton(getString(R.string.okay), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    mAlertDialog.show();
}

From source file:com.cenkgun.chatty.MainActivity.java

private void addPhoto() {
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("image/*");
    startActivityForResult(intent, REQUEST_IMAGE);
}

From source file:com.anykey.balala.activity.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addCategory(Intent.CATEGORY_HOME);
        startActivity(intent);/*  www  .j a  va  2 s .  c  o m*/
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.krayzk9s.imgurholo.ui.AccountFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    ImgurHoloActivity activity = (ImgurHoloActivity) getActivity();
    if (activity.getApiCall().settings.getString("theme", MainActivity.HOLO_LIGHT)
            .equals(MainActivity.HOLO_LIGHT))
        inflater.inflate(R.menu.main, menu);
    else//from  w  ww.j a  v  a  2 s  .  c  o m
        inflater.inflate(R.menu.main_dark, menu);
    menu.findItem(R.id.action_search).setVisible(true);
    menu.findItem(R.id.action_refresh).setVisible(true);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    mSearchView = (SearchView) searchItem.getActionView();
    mSearchView.setQueryHint("Lookup Users");
    SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            // Do nothing
            return true;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            Log.d("searching", mSearchView.getQuery() + "");
            Intent intent = new Intent();
            intent.putExtra("username", mSearchView.getQuery().toString());
            intent.setAction(ImgurHoloActivity.ACCOUNT_INTENT);
            intent.addCategory(Intent.CATEGORY_DEFAULT);
            startActivity(intent);
            return true;
        }
    };
    mSearchView.setOnQueryTextListener(queryTextListener);
}

From source file:at.tomtasche.reader.ui.activity.MainActivity.java

public void findDocument() {

    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    // remove mime-type because most apps don't support ODF mime-types
    intent.setType("application/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    PackageManager pm = getPackageManager();
    final List<ResolveInfo> targets = pm.queryIntentActivities(intent, 0);
    int size = targets.size();
    String[] targetNames = new String[size];
    for (int i = 0; i < size; i++) {
        targetNames[i] = targets.get(i).loadLabel(pm).toString();
    }//w  w  w. j  a  v  a 2  s  .  co  m

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.dialog_choose_filemanager);
    builder.setItems(targetNames, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            ResolveInfo target = targets.get(which);
            if (target == null) {
                return;
            }

            intent.setComponent(new ComponentName(target.activityInfo.packageName, target.activityInfo.name));

            try {
                startActivityForResult(intent, 42);
            } catch (Exception e) {
                e.printStackTrace();

                showCrouton(R.string.crouton_error_open_app, new Runnable() {

                    @Override
                    public void run() {
                        findDocument();
                    }
                }, AppMsg.STYLE_ALERT);
            }

            dialog.dismiss();
        }
    });
    builder.show();
}

From source file:com.krayzk9s.imgurholo.ui.AlbumsFragment.java

void selectItem(int position) {
    Intent intent = new Intent();
    String id = ids.get(position);
    intent.putExtra("imageCall", "3/album/" + id);
    intent.putExtra("id", id);
    intent.setAction(ImgurHoloActivity.IMAGES_INTENT);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    startActivity(intent);/* www. j  a va2  s  .  c  o  m*/
}

From source file:com.gigaset.home.Home.java

/**
 * Loads the list of installed applications in mApplications.
 *//*  ww  w . ja v a 2 s.c o  m*/
private void loadApplications(boolean isLaunching) {

    if (isLaunching && mApplications != null) {
        return;
    }

    PackageManager manager = getPackageManager();

    Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);

    final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0);
    Collections.sort(apps, new ResolveInfo.DisplayNameComparator(manager));

    if (apps != null) {
        final int count = apps.size();

        if (mApplications == null) {
            mApplications = new ArrayList<ApplicationInfo>(count);
        }
        mApplications.clear();

        ApplicationInfo application;
        // ********************* ADD Key Pad **********************************
        application = new ApplicationInfo();
        application.title = "Key Pad";
        application.icon = application.icon = getResources().getDrawable(R.drawable.main_screen_iocon_key_pad);
        application.setActivity(
                new ComponentName("com.android.contacts", "com.android.contacts.activities.DialtactsActivity"),
                Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        mApplications.add(application);

        // ********************* ADD Messages *********************************
        application = new ApplicationInfo();
        application.title = "Messages";
        application.icon = application.icon = getResources().getDrawable(R.drawable.main_screen_icon_messages);
        application.setActivity(new ComponentName("com.android.mms", "com.android.mms.ui.ConversationList"),
                Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        mApplications.add(application);

        // ********************* ADD Contacts *********************************
        application = new ApplicationInfo();
        application.title = "Contacts";
        application.icon = application.icon = getResources().getDrawable(R.drawable.main_screen_icon_contacts);
        application.setActivity(
                new ComponentName("com.android.contacts", "com.android.contacts.activities.PeopleActivity"),
                Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        mApplications.add(application);

        // ********************* ADD Call Log *********************************
        // http://hi-android.info/src/index.html            
        application = new ApplicationInfo();
        application.title = "Call List";
        application.icon = getResources().getDrawable(R.drawable.main_screen_icon_call_log);

        application.setActivityWithAction(Intent.ACTION_VIEW, CallLog.Calls.CONTENT_TYPE);
        mApplications.add(application);

        // ********************* ADD Browser **********************************
        application = new ApplicationInfo();
        application.title = "Browser";
        application.icon = application.icon = getResources().getDrawable(R.drawable.main_screen_icon_browser);
        application.setActivity(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity"),
                Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        mApplications.add(application);

        // ********************* ADD Call Settings ****************************
        application = new ApplicationInfo();
        application.title = "Call Settings";
        application.icon = application.icon = getResources()
                .getDrawable(R.drawable.main_screen_icon_call_settings);
        application.setActivity(new ComponentName("com.android.settings", "com.android.settings.Settings"),
                Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        mApplications.add(application);

        //            
        //            for (int i = 0; i < count; i++) 
        //            {
        //                ApplicationInfo application = new ApplicationInfo();
        //                ResolveInfo info = apps.get(i);
        //
        //                application.title = info.loadLabel(manager);
        //                application.setActivity(new ComponentName(
        //                        info.activityInfo.applicationInfo.packageName,
        //                        info.activityInfo.name),
        //                        Intent.FLAG_ACTIVITY_NEW_TASK
        //                        | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        //                
        //                Log.v("Home APP", "package neme= "+info.activityInfo.applicationInfo.packageName);
        //                Log.v("Home APP", "neme= "+info.activityInfo.name);
        //                Log.v("Home APP", "title= "+application.title);
        //                
        //                
        //                application.icon = info.activityInfo.loadIcon(manager);
        //                
        //                // Replace Icons
        //                if((application.title+"").equals("Browser"))    application.icon = getResources().getDrawable(R.drawable.main_screen_icon_browser);
        //                if((application.title+"").equals("Phone"))       application.icon = getResources().getDrawable(R.drawable.main_screen_iocon_key_pad);
        //                if((application.title+"").equals("People"))    application.icon = getResources().getDrawable(R.drawable.main_screen_icon_contacts);
        //                if((application.title+"").equals("Messaging"))    application.icon = getResources().getDrawable(R.drawable.main_screen_icon_messages);
        //                if((application.title+"").equals("Settings"))    application.icon = getResources().getDrawable(R.drawable.main_screen_icon_call_settings);
        //                //if((application.title+"").equals("Call Log")) application.icon = getResources().getDrawable(R.drawable.main_screen_icon_call_log);
        //                
        //                // Add Application
        //                if((application.title+"").equals("Browser"))    mApplications.add(application);
        //                if((application.title+"").equals("Phone"))       mApplications.add(application);
        //                if((application.title+"").equals("People"))    mApplications.add(application);
        //                if((application.title+"").equals("Messaging"))    mApplications.add(application);
        //                if((application.title+"").equals("Settings"))    mApplications.add(application);
        //
        //            }

    }
}

From source file:com.e2g.ecocicle.barcode.IntentIntegrator.java

/**
 * Shares the given text by encoding it as a barcode, such that another user can
 * scan the text off the screen of the device.
 *
 * @param text the text string to encode as a barcode
 * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants.
 * @return the {@link android.app.AlertDialog} that was shown to the user prompting them to download the app
 *   if a prompt was needed, or null otherwise
 *///  www  .j a va2s . c  om
public final AlertDialog shareText(CharSequence text, CharSequence type) {
    Intent intent = new Intent();
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setAction(BS_PACKAGE + ".ENCODE");
    intent.putExtra("ENCODE_TYPE", type);
    intent.putExtra("ENCODE_DATA", text);
    String targetAppPackage = findTargetAppPackage(intent);
    if (targetAppPackage == null) {
        return showDownloadDialog();
    }
    intent.setPackage(targetAppPackage);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    attachMoreExtras(intent);
    if (fragment == null) {
        activity.startActivity(intent);
    } else {
        fragment.startActivity(intent);
    }
    return null;
}

From source file:com.krayzk9s.imgurholo.ui.AccountFragment.java

private void selectItem(int position) {
    Intent intent;
    switch (position) {
    case 0://from  w w  w.j a va 2 s  . c  om
        intent = new Intent();
        intent.putExtra("username", "me");
        intent.setAction(ImgurHoloActivity.ALBUMS_INTENT);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        startActivity(intent);
        break;
    case 1:
        intent = new Intent();
        intent.putExtra("imageCall", "3/account/" + username + "/images");
        intent.setAction(ImgurHoloActivity.IMAGES_INTENT);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        startActivity(intent);
        break;
    case 2:
        intent = new Intent();
        intent.putExtra("imageCall", "3/account/" + username + "/likes");
        intent.setAction(ImgurHoloActivity.IMAGES_INTENT);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        startActivity(intent);
        break;
    case 3:
        intent = new Intent();
        intent.putExtra("username", username);
        intent.setAction(ImgurHoloActivity.COMMENTS_INTENT);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        startActivity(intent);
        break;
    default:
        break;
    }
}

From source file:com.google.zxing.integration.android.SupportIntentIntegrator.java

/**
 * Shares the given text by encoding it as a barcode, such that another user can
 * scan the text off the screen of the device.
 *
 * @param text the text string to encode as a barcode
 * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants.
 * @return the {@link AlertDialog} that was shown to the user prompting them to download the app
 *   if a prompt was needed, or null otherwise
 *//*from   w  w w .  ja v a  2s.  com*/
public final AlertDialog shareText(CharSequence text, CharSequence type) {
    Intent intent = new Intent();
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setAction(BS_PACKAGE + ".ENCODE");
    intent.putExtra("ENCODE_TYPE", type);
    intent.putExtra("ENCODE_DATA", text);
    String targetAppPackage = findTargetAppPackage(intent);
    if (targetAppPackage == null) {
        return showDownloadDialog();
    }
    intent.setPackage(targetAppPackage);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    attachMoreExtras(intent);
    if (fragment != null) {
        fragment.startActivity(intent);
    } else if (fragmentV4 != null) {
        fragmentV4.startActivity(intent);
    } else {
        activity.startActivity(intent);
    }
    return null;
}