Example usage for android.content Intent CATEGORY_DEFAULT

List of usage examples for android.content Intent CATEGORY_DEFAULT

Introduction

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

Prototype

String CATEGORY_DEFAULT

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

Click Source Link

Document

Set if the activity should be an option for the default action (center press) to perform on a piece of data.

Usage

From source file:com.gnuroot.rsinstaller.RSLauncherMain.java

/**
 * GNURoot Debian expects the following extras from install intents:
 *    1. launchType: This can be either launchTerm or launchXTerm. The command that is to be run after installation
 *       dictates this selection.// ww w . jav a 2 s . co  m
 *   2. command: This is the command that will be executed in proot after installation. Often, this will be a
 *      script stored in your custom tar file to install additional packages if needed or to execute the extension.
 *   3. customTar: This is the custom tar file you've created for your extension.
 * @return
  */
private Intent getLaunchIntent() {
    String command;
    Intent installIntent = new Intent("com.gnuroot.debian.LAUNCH");
    installIntent.setComponent(new ComponentName("com.gnuroot.debian", "com.gnuroot.debian.GNURootMain"));
    installIntent.addCategory(Intent.CATEGORY_DEFAULT);
    installIntent.putExtra("launchType", "launchXTerm");
    command = "#!/bin/bash\n"
            + "if [ ! -f /support/.rs_custom_passed ] || [ ! -f /support/.rs_updated ]; then\n"
            + "  /support/untargz rs_custom /support/rs_custom.tar.gz\n" + "fi\n"
            + "if [ -f /support/.rs_custom_passed ]; then\n"
            + "  if [ ! -f /support/.rs_script_passed ]; then\n"
            + "    sudo /support/blockingScript rs_script /support/oldschoolrs_install.sh\n" + "  fi\n"
            + "  if [ ! -f /support/.rs_script_updated ]; then\n"
            + "    sudo mv /support/rs_update /usr/bin/oldschoolrs\n" + "    if [ $? == 0 ]; then\n"
            + "      touch /support/.rs_script_updated\n" + "      sudo chmod 755 /usr/bin/oldschoolrs\n"
            + "    fi\n" + "  fi\n" + "  if [ -f /support/.rs_script_passed ]; then\n"
            + "    /usr/bin/oldschoolrs\n" + "  fi\n" + "fi\n";
    installIntent.putExtra("command", command);
    installIntent.putExtra("packageName", "com.gnuroot.rsinstaller");
    installIntent.putExtra("GNURootVersion", GNURootVersion);
    installIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    installIntent.setData(getTarUri());
    return installIntent;
}

From source file:me.xingrz.finder.EntriesActivity.java

protected Intent intentToView(Uri uri, String mime) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(uri, mime);/*from  w  w  w  . j  a v  a  2s.  c o m*/
    intent.addCategory(Intent.CATEGORY_DEFAULT);

    for (ResolveInfo resolved : getPackageManager().queryIntentActivities(intent, 0)) {
        if (BuildConfig.APPLICATION_ID.equals(resolved.activityInfo.packageName)) {
            intent.setClassName(this, resolved.activityInfo.name);
            intent.putExtra(EXTRA_ALLOW_BACK, true);
        }
    }

    return intent;
}

From source file:com.deadpixels.light.clipper.Settings.java

private void showSourceCode() {
    Intent showSourceIntent = new Intent();
    showSourceIntent.setAction(Intent.ACTION_VIEW);
    showSourceIntent.addCategory(Intent.CATEGORY_DEFAULT);
    showSourceIntent.setData(Uri.parse(SOURCE_URL));
    startActivity(showSourceIntent);//from  w  ww . ja  v a2 s .  c o m
}

From source file:gov.wa.wsdot.android.wsdot.ui.MountainPassesFragment.java

@Override
public void onResume() {
    super.onResume();

    IntentFilter filter = new IntentFilter("gov.wa.wsdot.android.wsdot.intent.action.MOUNTAIN_PASSES_RESPONSE");
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    mMountainPassesSyncReceiver = new MountainPassesSyncReceiver();
    getActivity().registerReceiver(mMountainPassesSyncReceiver, filter);
}

From source file:cn.ieclipse.af.demo.MainActivity.java

@Override
public void onCheckSuccess(final CheckUpdateController.CheckResponse info) {
    if (info != null) {
        DialogUtils.showAlert(this, android.R.drawable.ic_dialog_info, "?",
                TextUtils.isEmpty(info.description) ? "???" : info.description,
                new DialogInterface.OnClickListener() {
                    @Override/*from  w w  w .j  a  v  a  2 s  .c  o  m*/
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            Intent intent = new Intent(Intent.ACTION_VIEW);
                            intent.addCategory(Intent.CATEGORY_BROWSABLE);
                            intent.addCategory(Intent.CATEGORY_DEFAULT);
                            if (info.force) {
                                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            }
                            intent.setData(Uri.parse(info.downloadLink));
                            startActivityForResult(Intent.createChooser(intent, null), 0x01);
                        } catch (Exception e) {
                            DialogUtils.showToast(getApplicationContext(), "?");
                        } finally {

                        }
                    }
                }, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (info.force) {
                            finish();
                        }
                    }
                });
    }
}

From source file:gov.wa.wsdot.android.wsdot.ui.BorderWaitNorthboundFragment.java

@Override
public void onResume() {
    super.onResume();

    IntentFilter filter = new IntentFilter("gov.wa.wsdot.android.wsdot.intent.action.BORDER_WAIT_RESPONSE");
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    mBorderWaitSyncReceiver = new BorderWaitSyncReceiver();
    getActivity().registerReceiver(mBorderWaitSyncReceiver, filter);
}

From source file:io.github.mkjung.ivi.util.Permissions.java

private static Dialog createDialog(final Activity activity, boolean exit) {
    android.app.AlertDialog.Builder dialogBuilder = new android.app.AlertDialog.Builder(activity)
            .setTitle(activity.getString(R.string.allow_storage_access_title))
            .setMessage(activity.getString(R.string.allow_storage_access_description))
            .setIcon(android.R.drawable.ic_dialog_alert).setPositiveButton(
                    activity.getString(R.string.permission_ask_again), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int whichButton) {
                            SharedPreferences settings = PreferenceManager
                                    .getDefaultSharedPreferences(activity);
                            if (!settings.getBoolean("user_declined_storage_access", false))
                                requestStoragePermission(activity);
                            else {
                                Intent i = new Intent();
                                i.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
                                i.addCategory(Intent.CATEGORY_DEFAULT);
                                i.setData(Uri
                                        .parse("package:" + VLCApplication.getAppContext().getPackageName()));
                                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                try {
                                    activity.startActivity(i);
                                } catch (Exception ex) {
                                }/*  www.ja va 2s  .c  o m*/
                            }
                            SharedPreferences.Editor editor = settings.edit();
                            editor.putBoolean("user_declined_storage_access", true);
                            Util.commitPreferences(editor);
                        }
                    });
    if (exit) {
        dialogBuilder.setNegativeButton(activity.getString(R.string.exit_app),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        activity.finish();
                    }
                }).setCancelable(false);
    }
    return dialogBuilder.show();
}

From source file:gov.wa.wsdot.android.wsdot.ui.FerriesRouteSchedulesFragment.java

@Override
public void onResume() {
    super.onResume();

    IntentFilter filter = new IntentFilter(
            "gov.wa.wsdot.android.wsdot.intent.action.FERRIES_SCHEDULES_RESPONSE");
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    mFerriesSchedulesSyncReceiver = new FerriesSchedulesSyncReceiver();
    getActivity().registerReceiver(mFerriesSchedulesSyncReceiver, filter);
}

From source file:org.videolan.vlc.util.Permissions.java

private static Dialog createDialog(final Activity activity, boolean exit) {
    android.app.AlertDialog.Builder dialogBuilder = new android.app.AlertDialog.Builder(activity)
            .setTitle(activity.getString(R.string.allow_storage_access_title))
            .setMessage(activity.getString(R.string.allow_storage_access_description))
            .setIcon(android.R.drawable.ic_dialog_alert).setPositiveButton(
                    activity.getString(R.string.permission_ask_again), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int whichButton) {
                            SharedPreferences settings = PreferenceManager
                                    .getDefaultSharedPreferences(activity);
                            if (!settings.getBoolean("user_declined_storage_access", false))
                                requestStoragePermission(activity);
                            else {
                                Intent i = new Intent();
                                i.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
                                i.addCategory(Intent.CATEGORY_DEFAULT);
                                i.setData(Uri
                                        .parse("package:" + VLCApplication.getAppContext().getPackageName()));
                                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                try {
                                    activity.startActivity(i);
                                } catch (Exception ex) {
                                }/*from  w w w.  ja va2  s.c  om*/
                            }
                            SharedPreferences.Editor editor = settings.edit();
                            editor.putBoolean("user_declined_storage_access", true);
                            editor.apply();
                        }
                    });
    if (exit) {
        dialogBuilder.setNegativeButton(activity.getString(R.string.exit_app),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        activity.finish();
                    }
                }).setCancelable(false);
    }
    return dialogBuilder.show();
}

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// w w  w .  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);
}