List of usage examples for android.content Intent CATEGORY_DEFAULT
String CATEGORY_DEFAULT
To view the source code for android.content Intent CATEGORY_DEFAULT.
Click Source Link
From source file:gov.wa.wsdot.android.wsdot.service.FerriesSchedulesSyncService.java
@Override protected void onHandleIntent(Intent intent) { ContentResolver resolver = getContentResolver(); Cursor cursor = null;// w ww.ja v a2 s.co m long now = System.currentTimeMillis(); boolean shouldUpdate = true; String responseString = ""; DateFormat dateFormat = new SimpleDateFormat("MMMM d, yyyy h:mm a"); /** * 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[] { "ferries_schedules" }, 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) > (30 * 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(); try { URL url = new URL(FERRIES_SCHEDULES_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 jsonFile = ""; String line; while ((line = in.readLine()) != null) jsonFile += line; in.close(); JSONArray items = new JSONArray(jsonFile); List<ContentValues> schedules = new ArrayList<ContentValues>(); int numItems = items.length(); for (int i = 0; i < numItems; i++) { JSONObject item = items.getJSONObject(i); ContentValues schedule = new ContentValues(); schedule.put(FerriesSchedules.FERRIES_SCHEDULE_ID, item.getInt("RouteID")); schedule.put(FerriesSchedules.FERRIES_SCHEDULE_TITLE, item.getString("Description")); schedule.put(FerriesSchedules.FERRIES_SCHEDULE_DATE, item.getString("Date")); schedule.put(FerriesSchedules.FERRIES_SCHEDULE_ALERT, item.getString("RouteAlert")); schedule.put(FerriesSchedules.FERRIES_SCHEDULE_UPDATED, dateFormat .format(new Date(Long.parseLong(item.getString("CacheDate").substring(6, 19))))); if (starred.contains(item.getInt("RouteID"))) { schedule.put(FerriesSchedules.FERRIES_SCHEDULE_IS_STARRED, 1); } schedules.add(schedule); } // Purge existing travel times covered by incoming data resolver.delete(FerriesSchedules.CONTENT_URI, null, null); // Bulk insert all the new travel times resolver.bulkInsert(FerriesSchedules.CONTENT_URI, schedules.toArray(new ContentValues[schedules.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[] { "ferries_schedules" }); 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.FERRIES_SCHEDULES_RESPONSE"); broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT); broadcastIntent.putExtra("responseString", responseString); sendBroadcast(broadcastIntent); }
From source file:com.crearo.gpslogger.ui.fragments.display.GpsSimpleViewFragment.java
private void startInstalledAppDetailsActivity(final Activity context) { if (context == null) { return;/* w ww . j a v 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.sportsapp.MainActivity.java
private void openAppDetails() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(/*from w w w.ja v a2 s . c om*/ "? Camera? ? ? -> ??? ?"); builder.setPositiveButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setData(Uri.parse("package:" + getPackageName())); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivity(intent); } }); builder.setNegativeButton("?", null); builder.show(); }
From source file:se.leap.bitmaskclient.ConfigurationWizard.java
private void setUpProviderAPIResultReceiver() { providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler(), this); providerAPI_broadcast_receiver_update = new ProviderAPIBroadcastReceiver_Update(); IntentFilter update_intent_filter = new IntentFilter(ProviderAPI.UPDATE_PROGRESSBAR); update_intent_filter.addCategory(Intent.CATEGORY_DEFAULT); registerReceiver(providerAPI_broadcast_receiver_update, update_intent_filter); }
From source file:com.krayzk9s.imgurholo.activities.ImgurHoloActivity.java
public void imageSelected(ArrayList<JSONParcelable> data, int position) { FrameLayout displayFrag = (FrameLayout) findViewById(R.id.frame_layout_child); if (displayFrag == null) { // DisplayFragment (Fragment B) is not in the layout (handset layout), // so start DisplayActivity (Activity B) // and pass it the info about the selected item if (getApiCall().settings.getBoolean("ImagePagerEnabled", false) == false) { Intent intent = new Intent(); intent.putExtra("id", data.get(position)); Log.d("data", data.get(position).toString()); intent.setAction(ImgurHoloActivity.IMAGE_INTENT); intent.addCategory(Intent.CATEGORY_DEFAULT); startActivity(intent);/*from w ww . j a va 2s.c om*/ } else { Intent intent = new Intent(); intent.putExtra("ids", data); intent.putExtra("start", position); intent.setAction(ImgurHoloActivity.IMAGE_PAGER_INTENT); intent.addCategory(Intent.CATEGORY_DEFAULT); startActivity(intent); } } else { // DisplayFragment (Fragment B) is in the layout (tablet layout), // so tell the fragment to update try { if (data.get(position).getJSONObject().has("is_album") && data.get(position).getJSONObject().getBoolean("is_album")) { ImagesFragment fragment = new ImagesFragment(); Bundle bundle = new Bundle(); bundle.putString("imageCall", "3/album/" + data.get(position).getJSONObject().getString("id")); bundle.putString("id", data.get(position).getJSONObject().getString("id")); bundle.putParcelable("albumData", data.get(position)); fragment.setArguments(bundle); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.frame_layout_child, fragment).commitAllowingStateLoss(); } else { SingleImageFragment singleImageFragment = new SingleImageFragment(); Bundle bundle = new Bundle(); bundle.putBoolean("gallery", true); bundle.putParcelable("imageData", data.get(position)); singleImageFragment.setArguments(bundle); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.frame_layout_child, singleImageFragment) .commitAllowingStateLoss(); } } catch (JSONException e) { Log.e("Error!", e.toString()); } } }
From source file:gov.wa.wsdot.android.wsdot.service.HighwayAlertsSyncService.java
@SuppressLint("SimpleDateFormat") @Override//from w w w.j a v a 2s . c om protected void onHandleIntent(Intent intent) { ContentResolver resolver = getContentResolver(); Cursor cursor = null; long now = System.currentTimeMillis(); boolean shouldUpdate = true; String responseString = ""; DateFormat dateFormat = new SimpleDateFormat("MMMM d, yyyy h:mm a"); /** * 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, projection, Caches.CACHE_TABLE_NAME + " LIKE ?", new String[] { "highway_alerts" }, 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) > (5 * DateUtils.MINUTE_IN_MILLIS)); } } finally { if (cursor != null) { cursor.close(); } } // Tapping the refresh button will force a data refresh. boolean forceUpdate = intent.getBooleanExtra("forceUpdate", false); if (shouldUpdate || forceUpdate) { try { URL url = new URL(HIGHWAY_ALERTS_URL); URLConnection urlConn = url.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream())); String jsonFile = ""; String line; while ((line = in.readLine()) != null) { jsonFile += line; } in.close(); JSONObject obj = new JSONObject(jsonFile); JSONObject result = obj.getJSONObject("alerts"); JSONArray items = result.getJSONArray("items"); List<ContentValues> alerts = new ArrayList<ContentValues>(); int numItems = items.length(); for (int j = 0; j < numItems; j++) { JSONObject item = items.getJSONObject(j); JSONObject startRoadwayLocation = item.getJSONObject("StartRoadwayLocation"); ContentValues alertData = new ContentValues(); alertData.put(HighwayAlerts.HIGHWAY_ALERT_ID, item.getString("AlertID")); alertData.put(HighwayAlerts.HIGHWAY_ALERT_HEADLINE, item.getString("HeadlineDescription")); alertData.put(HighwayAlerts.HIGHWAY_ALERT_CATEGORY, item.getString("EventCategory")); alertData.put(HighwayAlerts.HIGHWAY_ALERT_PRIORITY, item.getString("Priority")); alertData.put(HighwayAlerts.HIGHWAY_ALERT_LATITUDE, startRoadwayLocation.getString("Latitude")); alertData.put(HighwayAlerts.HIGHWAY_ALERT_LONGITUDE, startRoadwayLocation.getString("Longitude")); alertData.put(HighwayAlerts.HIGHWAY_ALERT_ROAD_NAME, startRoadwayLocation.getString("RoadName")); alertData.put(HighwayAlerts.HIGHWAY_ALERT_LAST_UPDATED, dateFormat .format(new Date(Long.parseLong(item.getString("LastUpdatedTime").substring(6, 19))))); alerts.add(alertData); } // Purge existing highway alerts covered by incoming data resolver.delete(HighwayAlerts.CONTENT_URI, null, null); // Bulk insert all the new highway alerts resolver.bulkInsert(HighwayAlerts.CONTENT_URI, alerts.toArray(new ContentValues[alerts.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 + " LIKE ?", new String[] { "highway_alerts" }); 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.HIGHWAY_ALERTS_RESPONSE"); broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT); broadcastIntent.putExtra("responseString", responseString); sendBroadcast(broadcastIntent); }
From source file:gov.wa.wsdot.android.wsdot.ui.TrafficMapActivity.java
@Override protected void onResume() { super.onResume(); prepareMap();/*from w ww . ja v a2 s .c o m*/ setupLocationClientIfNeeded(); int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (ConnectionResult.SUCCESS == resultCode) { locationClient.connect(); } else { Toast.makeText(this, "Google Play services not available", Toast.LENGTH_SHORT).show(); } IntentFilter camerasFilter = new IntentFilter("gov.wa.wsdot.android.wsdot.intent.action.CAMERAS_RESPONSE"); camerasFilter.addCategory(Intent.CATEGORY_DEFAULT); mCamerasReceiver = new CamerasSyncReceiver(); registerReceiver(mCamerasReceiver, camerasFilter); IntentFilter alertsFilter = new IntentFilter( "gov.wa.wsdot.android.wsdot.intent.action.HIGHWAY_ALERTS_RESPONSE"); alertsFilter.addCategory(Intent.CATEGORY_DEFAULT); mHighwayAlertsSyncReceiver = new HighwayAlertsSyncReceiver(); registerReceiver(mHighwayAlertsSyncReceiver, alertsFilter); }
From source file:com.example.android.threadsample.DisplayActivity.java
@Override public void onCreate(Bundle stateBundle) { // Sets fullscreen-related flags for the display getWindow().setFlags(//from ww w . j av a 2s.co m WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR); // Calls the super method (required) super.onCreate(stateBundle); // Inflates the main View, which will be the host View for the fragments mMainView = getLayoutInflater().inflate(R.layout.fragmenthost, null); // Sets the content view for the Activity setContentView(mMainView); /* * Creates an intent filter for DownloadStateReceiver that intercepts broadcast Intents */ // The filter's action is BROADCAST_ACTION IntentFilter statusIntentFilter = new IntentFilter(Constants.BROADCAST_ACTION); // Sets the filter's category to DEFAULT statusIntentFilter.addCategory(Intent.CATEGORY_DEFAULT); // Instantiates a new DownloadStateReceiver mDownloadStateReceiver = new DownloadStateReceiver(); // Registers the DownloadStateReceiver and its intent filters LocalBroadcastManager.getInstance(this).registerReceiver(mDownloadStateReceiver, statusIntentFilter); /* * Creates intent filters for the FragmentDisplayer */ // One filter is for the action ACTION_VIEW_IMAGE IntentFilter displayerIntentFilter = new IntentFilter(Constants.ACTION_VIEW_IMAGE); // Adds a data filter for the HTTP scheme displayerIntentFilter.addDataScheme("http"); // Registers the receiver LocalBroadcastManager.getInstance(this).registerReceiver(mFragmentDisplayer, displayerIntentFilter); // Creates a second filter for ACTION_ZOOM_IMAGE displayerIntentFilter = new IntentFilter(Constants.ACTION_ZOOM_IMAGE); // Registers the receiver LocalBroadcastManager.getInstance(this).registerReceiver(mFragmentDisplayer, displayerIntentFilter); // Gets an instance of the support library FragmentManager FragmentManager localFragmentManager = getSupportFragmentManager(); /* * Detects if side-by-side display should be enabled. It's only available on xlarge and * sw600dp devices (for example, tablets). The setting in res/values/ is "false", but this * is overridden in values-xlarge and values-sw600dp. */ mSideBySide = getResources().getBoolean(R.bool.sideBySide); /* * Detects if hiding navigation controls should be enabled. On xlarge andsw600dp, it should * be false, to avoid having the user enter an additional tap. */ mHideNavigation = getResources().getBoolean(R.bool.hideNavigation); /* * Adds the back stack change listener defined in this Activity as the listener for the * FragmentManager. See the method onBackStackChanged(). */ localFragmentManager.addOnBackStackChangedListener(this); // If the incoming state of the Activity is null, sets the initial view to be thumbnails if (null == stateBundle) { // Starts a Fragment transaction to track the stack FragmentTransaction localFragmentTransaction = localFragmentManager.beginTransaction(); // Adds the PhotoThumbnailFragment to the host View localFragmentTransaction.add(R.id.fragmentHost, new PhotoThumbnailFragment(), Constants.THUMBNAIL_FRAGMENT_TAG); // Commits this transaction to display the Fragment localFragmentTransaction.commit(); // The incoming state of the Activity isn't null. } else { // Gets the previous state of the fullscreen indicator mFullScreen = stateBundle.getBoolean(Constants.EXTENDED_FULLSCREEN); // Sets the fullscreen flag to its previous state setFullScreen(mFullScreen); // Gets the previous backstack entry count. mPreviousStackCount = localFragmentManager.getBackStackEntryCount(); } }
From source file:com.enstage.wibmo.sdk.inapp.InAppInitActivity.java
public static void startInAppReadinessCheck(Activity activity) { Log.d(TAG, "startInAppReadinessCheck"); String targetAppPackage = WibmoSDK.getWibmoIntentActionPackage(); Intent intent = new Intent(targetAppPackage + ".ReadinessChecker"); intent.addCategory(Intent.CATEGORY_DEFAULT); if (WibmoSDK.getWibmoAppPackage() != null) { intent.setPackage(WibmoSDK.getWibmoAppPackage()); }/*from www .ja v a 2s . c om*/ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); //causes to iap to be cancelled when app returned by icon launch activity.startActivityForResult(intent, REQUEST_CODE_IAP_READY); }
From source file:io.github.mkjung.ivi.util.Permissions.java
private static Dialog createDialogCompat(final Activity activity, boolean exit) { AlertDialog.Builder dialogBuilder = new 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) { }/* w ww .j a v a 2 s . com*/ } 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(); }