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:gov.wa.wsdot.android.wsdot.ui.FerriesRouteSchedulesDayDeparturesFragment.java

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

    IntentFilter filter = new IntentFilter(
            "gov.wa.wsdot.android.wsdot.intent.action.FERRIES_TERMINAL_SAILING_SPACE_RESPONSE");
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    ferriesTerminalSyncReceiver = new FerriesTerminalSyncReceiver();
    getActivity().registerReceiver(ferriesTerminalSyncReceiver, filter);
}

From source file:com.farmerbb.secondscreen.util.U.java

public static String uiRefreshCommand2(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

    // For better reliability, we execute the UI refresh while on the home screen
    Intent homeIntent = new Intent(Intent.ACTION_MAIN);
    homeIntent.addCategory(Intent.CATEGORY_HOME);
    homeIntent.addCategory(Intent.CATEGORY_DEFAULT);
    homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(homeIntent);/*from  w  w w .  j a v a2  s  .c  o m*/

    // Kill all background processes, in order to fully refresh UI
    PackageManager pm = context.getPackageManager();
    List<ApplicationInfo> packages = pm.getInstalledApplications(0);
    for (ApplicationInfo packageInfo : packages) {
        if (!packageInfo.packageName.equalsIgnoreCase(context.getPackageName()))
            am.killBackgroundProcesses(packageInfo.packageName);
    }

    // Get launcher package name
    final ResolveInfo mInfo = pm.resolveActivity(homeIntent, 0);

    return "sleep 1 && am force-stop " + mInfo.activityInfo.applicationInfo.packageName;
}

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);/*from  w ww . j  av  a  2s .co  m*/
}

From source file:Utils.GenericUtils.java

public final AlertDialog initiateScan(FragmentActivity fa, Collection<String> desiredBarcodeFormats) {
    Intent intentScan = new Intent("com.google.zxing.client.android.SCAN");

    intentScan.addCategory(Intent.CATEGORY_DEFAULT);
    intentScan.putExtra("SCAN_FORMATS", "QR_CODE_MODE");
    fa.startActivityForResult(intentScan, 312 /*IntentIntegrator.REQUEST_CODE*/);

    String targetAppPackage = "ET - QRCODE SCANNER";
    intentScan.setPackage(targetAppPackage);
    intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    return null;//from  w w w.j  a v  a  2 s.com
}

From source file:gov.wa.wsdot.android.wsdot.service.MountainPassesSyncService.java

@Override
protected void onHandleIntent(Intent intent) {
    ContentResolver resolver = getContentResolver();
    Cursor cursor = null;/*  ww  w.  j  a  v a2 s .  c o  m*/
    long now = System.currentTimeMillis();
    boolean shouldUpdate = true;
    String responseString = "";

    /** 
     * Check the cache table for the last time data was downloaded. If we are within
     * the allowed time period, don't sync, otherwise get fresh data from the server.
     */
    try {
        cursor = resolver.query(Caches.CONTENT_URI, new String[] { Caches.CACHE_LAST_UPDATED },
                Caches.CACHE_TABLE_NAME + " LIKE ?", new String[] { "mountain_passes" }, null);

        if (cursor != null && cursor.moveToFirst()) {
            long lastUpdated = cursor.getLong(0);
            //long deltaMinutes = (now - lastUpdated) / DateUtils.MINUTE_IN_MILLIS;
            //Log.d(DEBUG_TAG, "Delta since last update is " + deltaMinutes + " min");
            shouldUpdate = (Math.abs(now - lastUpdated) > (15 * DateUtils.MINUTE_IN_MILLIS));
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }

    // Ability to force a refresh of camera data.
    boolean forceUpdate = intent.getBooleanExtra("forceUpdate", false);

    if (shouldUpdate || forceUpdate) {
        List<Integer> starred = new ArrayList<Integer>();

        starred = getStarred();
        buildWeatherPhrases();

        try {
            URL url = new URL(MOUNTAIN_PASS_URL);
            URLConnection urlConn = url.openConnection();

            BufferedInputStream bis = new BufferedInputStream(urlConn.getInputStream());
            GZIPInputStream gzin = new GZIPInputStream(bis);
            InputStreamReader is = new InputStreamReader(gzin);
            BufferedReader in = new BufferedReader(is);

            String mDateUpdated = "";
            String jsonFile = "";
            String line;
            while ((line = in.readLine()) != null)
                jsonFile += line;
            in.close();

            JSONObject obj = new JSONObject(jsonFile);
            JSONObject result = obj.getJSONObject("GetMountainPassConditionsResult");
            JSONArray passConditions = result.getJSONArray("PassCondition");
            String weatherCondition;
            Integer weather_image;
            Integer forecast_weather_image;
            List<ContentValues> passes = new ArrayList<ContentValues>();

            int numConditions = passConditions.length();
            for (int j = 0; j < numConditions; j++) {
                JSONObject pass = passConditions.getJSONObject(j);
                ContentValues passData = new ContentValues();
                weatherCondition = pass.getString("WeatherCondition");
                weather_image = getWeatherImage(weatherPhrases, weatherCondition);

                String tempDate = pass.getString("DateUpdated");

                try {
                    tempDate = tempDate.replace("[", "");
                    tempDate = tempDate.replace("]", "");

                    String[] a = tempDate.split(",");
                    StringBuilder sb = new StringBuilder();
                    for (int m = 0; m < 5; m++) {
                        sb.append(a[m]);
                        sb.append(",");
                    }
                    tempDate = sb.toString().trim();
                    tempDate = tempDate.substring(0, tempDate.length() - 1);
                    Date date = parseDateFormat.parse(tempDate);
                    mDateUpdated = displayDateFormat.format(date);
                } catch (Exception e) {
                    Log.e(DEBUG_TAG, "Error parsing date: " + tempDate, e);
                    mDateUpdated = "N/A";
                }

                JSONArray forecasts = pass.getJSONArray("Forecast");
                JSONArray forecastItems = new JSONArray();

                int numForecasts = forecasts.length();
                for (int l = 0; l < numForecasts; l++) {
                    JSONObject forecast = forecasts.getJSONObject(l);

                    if (isNight(forecast.getString("Day"))) {
                        forecast_weather_image = getWeatherImage(weatherPhrasesNight,
                                forecast.getString("ForecastText"));
                    } else {
                        forecast_weather_image = getWeatherImage(weatherPhrases,
                                forecast.getString("ForecastText"));
                    }

                    forecast.put("weather_icon", forecast_weather_image);

                    if (l == 0) {
                        if (weatherCondition.equals("")) {
                            weatherCondition = forecast.getString("ForecastText").split("\\.")[0] + ".";
                            weather_image = forecast_weather_image;
                        }
                    }

                    forecastItems.put(forecast);
                }

                passData.put(MountainPasses.MOUNTAIN_PASS_ID, pass.getString("MountainPassId"));
                passData.put(MountainPasses.MOUNTAIN_PASS_NAME, pass.getString("MountainPassName"));
                passData.put(MountainPasses.MOUNTAIN_PASS_WEATHER_ICON, weather_image);
                passData.put(MountainPasses.MOUNTAIN_PASS_FORECAST, forecastItems.toString());
                passData.put(MountainPasses.MOUNTAIN_PASS_WEATHER_CONDITION, weatherCondition);
                passData.put(MountainPasses.MOUNTAIN_PASS_DATE_UPDATED, mDateUpdated);
                passData.put(MountainPasses.MOUNTAIN_PASS_CAMERA, pass.getString("Cameras"));
                passData.put(MountainPasses.MOUNTAIN_PASS_ELEVATION, pass.getString("ElevationInFeet"));
                passData.put(MountainPasses.MOUNTAIN_PASS_TRAVEL_ADVISORY_ACTIVE,
                        pass.getString("TravelAdvisoryActive"));
                passData.put(MountainPasses.MOUNTAIN_PASS_ROAD_CONDITION, pass.getString("RoadCondition"));
                passData.put(MountainPasses.MOUNTAIN_PASS_TEMPERATURE,
                        pass.getString("TemperatureInFahrenheit"));
                JSONObject restrictionOne = pass.getJSONObject("RestrictionOne");
                passData.put(MountainPasses.MOUNTAIN_PASS_RESTRICTION_ONE,
                        restrictionOne.getString("RestrictionText"));
                passData.put(MountainPasses.MOUNTAIN_PASS_RESTRICTION_ONE_DIRECTION,
                        restrictionOne.getString("TravelDirection"));
                JSONObject restrictionTwo = pass.getJSONObject("RestrictionTwo");
                passData.put(MountainPasses.MOUNTAIN_PASS_RESTRICTION_TWO,
                        restrictionTwo.getString("RestrictionText"));
                passData.put(MountainPasses.MOUNTAIN_PASS_RESTRICTION_TWO_DIRECTION,
                        restrictionTwo.getString("TravelDirection"));

                if (starred.contains(Integer.parseInt(pass.getString("MountainPassId")))) {
                    passData.put(MountainPasses.MOUNTAIN_PASS_IS_STARRED, 1);
                }

                passes.add(passData);

            }

            // Purge existing mountain passes covered by incoming data
            resolver.delete(MountainPasses.CONTENT_URI, null, null);
            // Bulk insert all the new mountain passes
            resolver.bulkInsert(MountainPasses.CONTENT_URI, passes.toArray(new ContentValues[passes.size()]));
            // Update the cache table with the time we did the update
            ContentValues values = new ContentValues();
            values.put(Caches.CACHE_LAST_UPDATED, System.currentTimeMillis());
            resolver.update(Caches.CONTENT_URI, values, Caches.CACHE_TABLE_NAME + "=?",
                    new String[] { "mountain_passes" });

            responseString = "OK";
        } catch (Exception e) {
            Log.e(DEBUG_TAG, "Error: " + e.getMessage());
            responseString = e.getMessage();
        }

    } else {
        responseString = "NOP";
    }

    Intent broadcastIntent = new Intent();
    broadcastIntent.setAction("gov.wa.wsdot.android.wsdot.intent.action.MOUNTAIN_PASSES_RESPONSE");
    broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
    broadcastIntent.putExtra("responseString", responseString);
    sendBroadcast(broadcastIntent);
}

From source file:com.codyy.rx.permissions.RxPermissions.java

/**
 * ???/* w  w w  .  jav a  2s .  c o m*/
 *
 * @param context     context
 * @param packageName ??
 */
public static void openPermissionSettings(@NonNull Context context, @NonNull String packageName) {
    Intent intent = new Intent();
    intent.setAction("miui.intent.action.APP_PERM_EDITOR");//??MIUI???
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.putExtra("extra_pkgname", packageName);
    if (intent.resolveActivity(context.getPackageManager()) != null) {
        context.startActivity(intent);
    } else {
        Uri packageURI = Uri.parse("package:" + packageName);
        intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", packageURI);//???
        if (intent.resolveActivity(context.getPackageManager()) != null) {
            context.startActivity(intent);
        } else {
            Toast.makeText(context, "???", Toast.LENGTH_SHORT).show();
        }
    }
}

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

/**
 * Initiates a scan, using the specified camera, only for a certain set of barcode types, given as strings corresponding
 * to their names in ZXing's {@code BarcodeFormat} class like "UPC_A". You can supply constants
 * like {@link #PRODUCT_CODE_TYPES} for example.
 *
 * @param desiredBarcodeFormats names of {@code BarcodeFormat}s to scan for
 * @param cameraId camera ID of the camera to use. A negative value means "no preference".
 * @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
 *///w w w. j  ava  2 s.c  o  m
public final AlertDialog initiateScan(Collection<String> desiredBarcodeFormats, int cameraId) {
    Intent intentScan = new Intent(BS_PACKAGE + ".SCAN");
    intentScan.addCategory(Intent.CATEGORY_DEFAULT);

    // check which types of codes to scan for
    if (desiredBarcodeFormats != null) {
        // set the desired barcode types
        StringBuilder joinedByComma = new StringBuilder();
        for (String format : desiredBarcodeFormats) {
            if (joinedByComma.length() > 0) {
                joinedByComma.append(',');
            }
            joinedByComma.append(format);
        }
        intentScan.putExtra("SCAN_FORMATS", joinedByComma.toString());
    }

    // check requested camera ID
    if (cameraId >= 0) {
        intentScan.putExtra("SCAN_CAMERA_ID", cameraId);
    }

    String targetAppPackage = findTargetAppPackage(intentScan);
    if (targetAppPackage == null) {
        return showDownloadDialog();
    }
    intentScan.setPackage(targetAppPackage);
    intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    attachMoreExtras(intentScan);
    startActivityForResult(intentScan, REQUEST_CODE);
    return null;
}

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

private void selectItem(int position) {
    Intent intent;/*  w ww.j av  a 2 s. c om*/
    switch (position) {
    case 0:
        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.iss.android.wearable.datalayer.MainActivity.java

private void RegisterBroadcastsReceiver() {

    IntentFilter filter = new IntentFilter();
    filter.addAction(SensorsDataService.ACTION_BATTERY_STATUS);
    filter.addAction(SensorsDataService.ACTION_HR);
    filter.addAction(SensorsDataService.NEW_MESSAGE_AVAILABLE);
    filter.addAction(SensorsDataService.ASK_USER_FOR_RPE);
    filter.addAction(SensorsDataService.UPDATE_TIMER_VALUE);
    filter.addAction(SensorsDataService.UPDATE_GPS_PARAMS);
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    registerReceiver(br, filter);//from   w w w. ja  v a2 s  .c  om

}

From source file:com.rickendirk.rsgwijzigingen.ZoekService.java

private void broadcastResult(Wijzigingen wijzigingen, Boolean clusters_enabled) {
    Intent broadcastIntent = new Intent();
    broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
    broadcastIntent.setAction(MainFragment.ZoekReceiver.ACTION_RESP); //Nodig voor intentfilter
    broadcastIntent.putExtra("wijzigingen", wijzigingen);
    if (clusters_enabled) {
        broadcastIntent.putExtra("clustersAan", true);
    } else {/*from  www .  j  a v a 2  s .c  o  m*/
        broadcastIntent.putExtra("clustersAan", false);
    }
    sendBroadcast(broadcastIntent);
}