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.gnuroot.debian.GNURootMain.java

private void setupFirstHalf() {
    errOcc = false;/*w ww . j av  a2  s.c  o m*/

    expectingResult = true;
    Intent downloadIntent = new Intent();
    downloadIntent.addCategory(Intent.CATEGORY_DEFAULT);
    downloadIntent.setClassName("com.gnuroot.debian", "com.gnuroot.debian.GNURootDownloaderActivity");
    startActivityForResult(downloadIntent, 0);
}

From source file:com.crearo.gpslogger.ui.fragments.display.GpsSimpleViewFragment.java

private void startInstalledAppDetailsActivity(final Activity context) {
    if (context == null) {
        return;/* w ww  .j av  a  2s  .  com*/
    }
    final Intent i = new Intent();
    i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    i.addCategory(Intent.CATEGORY_DEFAULT);
    i.setData(Uri.parse("package:" + context.getPackageName()));
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    context.startActivity(i);
}

From source file:com.hmsoft.weargoproremote.services.WearMessageHandlerService.java

void updateNotification(String contentText) {
    if (mNotificationBuilder == null) {
        Context context = getApplicationContext();
        Intent activityIntent = new Intent(context, MobileMainActivity.class);
        activityIntent.setAction(Intent.ACTION_MAIN);
        activityIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        activityIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NEW_TASK);

        Intent stopIntent = new Intent(context, WearMessageHandlerService.class);
        stopIntent.setAction(ACTION_STOP);

        mNotificationBuilder = (new Builder(this)).setSmallIcon(R.drawable.icon_notification)
                .setContentTitle(getString(R.string.notification_tittle))
                .setContentIntent(PendingIntent.getActivity(context, 0, activityIntent, 0)).setLocalOnly(true)
                .addAction(R.drawable.icon_power, getString(R.string.action_stop),
                        PendingIntent.getService(context, 0, stopIntent, 0));
    }//from  ww  w .  j a va 2  s . c  om

    mNotificationBuilder.setContentText(contentText);
    startForeground(1, mNotificationBuilder.build());
}

From source file:com.first.akashshrivastava.showernow.ShowerActivity.java

@Override
public void onBackPressed() { //if back is pressed the application closes
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);/*from   www.  j a va 2 s  .  c o m*/
}

From source file:com.android.leanlauncher.IconCache.java

public ArrayMap<String, String> getAvailableIconPacks() {
    ArrayMap<String, String> availableIconPacks = new ArrayMap<>();

    PackageManager pm = mContext.getPackageManager();

    // fetch installed icon packs for popular launchers
    Intent novaIntent = new Intent(Intent.ACTION_MAIN);
    novaIntent.addCategory(NOVA_LAUNCHER_THEME_NAME);
    List<ResolveInfo> novaTheme = pm.queryIntentActivities(novaIntent, PackageManager.GET_META_DATA);
    List<ResolveInfo> goTheme = pm.queryIntentActivities(new Intent(GO_LAUNCHER_THEME_NAME),
            PackageManager.GET_META_DATA);

    // merge those lists
    List<ResolveInfo> rinfo = new ArrayList<>(novaTheme);
    rinfo.addAll(goTheme);//from   w w  w.  jav a 2  s .  c  om

    for (ResolveInfo ri : rinfo) {
        String packageName = ri.activityInfo.packageName;

        try {
            ApplicationInfo ai = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
            String label = pm.getApplicationLabel(ai).toString();
            Log.d(TAG, "Icon package = " + packageName + " title " + label);
            availableIconPacks.put(packageName, label);
        } catch (NameNotFoundException e) {
            Log.e(TAG, "Package not found = " + e);
        }
    }

    return availableIconPacks;
}

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

private void selectItem(int position) {
    Intent intent = new Intent();
    JSONParcelable jsonParcelable = new JSONParcelable();
    jsonParcelable.setJSONObject(messageAdapter.getItem(position).getJSONObject());
    intent.putExtra("data", jsonParcelable);
    intent.setAction(ImgurHoloActivity.MESSAGE_INTENT);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    startActivity(intent);// w ww  . j  ava2 s  . c o  m
}

From source file:de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.java

private void _open(String url, String contentType, String packageId, String activity,
        CallbackContext callbackContext, Bundle viewerOptions) throws JSONException {
    clearTempFiles();//  w  w  w  . j a v  a2 s .co m

    File file = getAccessibleFile(url);

    if (file != null && file.exists() && file.isFile()) {
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            Uri path = Uri.fromFile(file);

            // @see http://stackoverflow.com/questions/2780102/open-another-application-from-your-own-intent
            intent.addCategory(Intent.CATEGORY_EMBED);
            intent.setDataAndType(path, contentType);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.putExtra(this.getClass().getName(), viewerOptions);
            //activity needs fully qualified name here
            intent.setComponent(new ComponentName(packageId, packageId + "." + activity));

            this.callbackContext = callbackContext;
            this.cordova.startActivityForResult(this, intent, REQUEST_CODE_OPEN);

            // send shown event
            JSONObject successObj = new JSONObject();
            successObj.put(Result.STATUS, PluginResult.Status.OK.ordinal());
            PluginResult result = new PluginResult(PluginResult.Status.OK, successObj);
            // need to keep callback for close event
            result.setKeepCallback(true);
            callbackContext.sendPluginResult(result);
        } catch (android.content.ActivityNotFoundException e) {
            JSONObject errorObj = new JSONObject();
            errorObj.put(Result.STATUS, PluginResult.Status.ERROR.ordinal());
            errorObj.put(Result.MESSAGE, "Activity not found: " + e.getMessage());
            callbackContext.error(errorObj);
        }
    } else {
        JSONObject errorObj = new JSONObject();
        errorObj.put(Result.STATUS, PluginResult.Status.ERROR.ordinal());
        errorObj.put(Result.MESSAGE, "File not found");
        callbackContext.error(errorObj);
    }
}

From source file:com.gnuroot.debian.GNURootMain.java

public void reconnectX() {
    Intent vncIntent = new Intent("com.gnuroot.debian.CONNECT_VNC_VIEWER");
    vncIntent.addCategory(Intent.CATEGORY_DEFAULT);
    vncIntent.putExtra("packageName", getPackageName());
    startService(vncIntent);/*from  w w  w . j  ava2  s  .c  o  m*/
}

From source file:de.stadtrallye.rallyesoft.model.pictures.PictureManager.java

/**
 * Get an intent to either take a picture with the camera app or select an app that can pick an existing picture
 */// w w w  .j a  v a  2  s  .c  om
public Intent startPictureTakeOrSelect(SourceHint sourceHint) {
    //Attention: Our RequestCode will not be used for the result, if a jpeg is picked, data.getType will contain image/jpeg, if the picture was just taken with the camera it will be null
    Intent pickIntent = new Intent();
    pickIntent.setType("image/jpeg");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        pickIntent.setAction(Intent.ACTION_OPEN_DOCUMENT);
        pickIntent.addCategory(Intent.CATEGORY_OPENABLE);
    } else {
        pickIntent.setAction(Intent.ACTION_GET_CONTENT);
    }

    Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    Uri fileUri = getPicturePlaceholderUri(PictureManager.MEDIA_TYPE_IMAGE, sourceHint); // reserve a filename to save the image
    takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
    takePhotoIntent.putExtra("return-data", true);

    Intent chooserIntent = Intent.createChooser(pickIntent, context.getString(R.string.select_take_picture));
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { takePhotoIntent });

    return chooserIntent;
}

From source file:com.googlecode.android_scripting.rpc.MethodDescriptor.java

public static Object buildIntent(JSONObject jsonObject) throws JSONException {
    Intent intent = new Intent();
    if (jsonObject.has("action")) {
        intent.setAction(jsonObject.getString("action"));
    }//ww  w.j  av  a2s.  c o  m
    if (jsonObject.has("data") && jsonObject.has("type")) {
        intent.setDataAndType(Uri.parse(jsonObject.optString("data", null)),
                jsonObject.optString("type", null));
    } else if (jsonObject.has("data")) {
        intent.setData(Uri.parse(jsonObject.optString("data", null)));
    } else if (jsonObject.has("type")) {
        intent.setType(jsonObject.optString("type", null));
    }
    if (jsonObject.has("packagename") && jsonObject.has("classname")) {
        intent.setClassName(jsonObject.getString("packagename"), jsonObject.getString("classname"));
    }
    if (jsonObject.has("flags")) {
        intent.setFlags(jsonObject.getInt("flags"));
    }
    if (!jsonObject.isNull("extras")) {
        AndroidFacade.putExtrasFromJsonObject(jsonObject.getJSONObject("extras"), intent);
    }
    if (!jsonObject.isNull("categories")) {
        JSONArray categories = jsonObject.getJSONArray("categories");
        for (int i = 0; i < categories.length(); i++) {
            intent.addCategory(categories.getString(i));
        }
    }
    return intent;
}