List of usage examples for android.content Intent addCategory
public @NonNull Intent addCategory(String category)
From source file:com.doomy.padlock.MainActivity.java
private void openAboutDialog() { LayoutInflater mLayoutInflater = LayoutInflater.from(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.orangeDark), PorterDuff.Mode.SRC_ATOP); mStudio.setColorFilter(getResources().getColor(R.color.orange), PorterDuff.Mode.SRC_ATOP); mGitHub.setColorFilter(getResources().getColor(R.color.greyMaterialDark), PorterDuff.Mode.SRC_ATOP); mImageViewGitHub.setOnClickListener(new View.OnClickListener() { @Override// w ww. ja va2s . co m 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(MainActivity.this, R.style.DialogTheme); 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.google.android.demos.jamendo.app.AlbumActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); int groupId = MENU_GROUP_INTENT_OPTIONS; int itemId = Menu.NONE; int order = Menu.NONE; ComponentName caller = getComponentName(); Intent[] specifics = null;//from www . j a v a2 s. c om Intent intent = new Intent(); long id = ContentUris.parseId(getIntent().getData()); intent.setDataAndType(JamendoContract.createPlaylistUri(JamendoContract.FORMAT_M3U, Albums.ID, id), JamendoContract.CONTENT_TYPE_M3U); intent.addCategory(Intent.CATEGORY_ALTERNATIVE); int flags = 0; MenuItem[] outSpecificItems = null; menu.addIntentOptions(groupId, itemId, order, caller, specifics, intent, flags, outSpecificItems); return menu.hasVisibleItems(); }
From source file:com.guayaba.tapir.ui.fragments.ThemeFragment.java
/** * {@inheritDoc}/*from w ww . j a v a2 s .co m*/ */ @Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final Intent apolloThemeIntent = new Intent("com.guayaba.tapir.THEMES"); apolloThemeIntent.addCategory("android.intent.category.DEFAULT"); mPackageManager = getActivity().getPackageManager(); mThemes = mPackageManager.queryIntentActivities(apolloThemeIntent, 0); mEntries = new String[mThemes.size() + 1]; mValues = new String[mThemes.size() + 1]; mThemePreview = new Drawable[mThemes.size() + 1]; // Default items mEntries[0] = getString(R.string.app_name); // mValues[0] = ThemeUtils.APOLLO_PACKAGE; mThemePreview[0] = getResources().getDrawable(R.drawable.theme_preview); for (int i = 0; i < mThemes.size(); i++) { mThemePackageName = mThemes.get(i).activityInfo.packageName.toString(); mThemeName = mThemes.get(i).loadLabel(mPackageManager).toString(); mEntries[i + 1] = mThemeName; mValues[i + 1] = mThemePackageName; // Theme resources try { mThemeResources = mPackageManager.getResourcesForApplication(mThemePackageName.toString()); } catch (final NameNotFoundException ignored) { } // Theme preview final int previewId = mThemeResources.getIdentifier("theme_preview", "drawable", //$NON-NLS-2$ mThemePackageName.toString()); if (previewId != 0) { mThemePreview[i + 1] = mThemeResources.getDrawable(previewId); } } // Initialize the Adapter mAdapter = new ThemesAdapter(getActivity(), R.layout.fragment_themes_base); // Bind the data mGridView.setAdapter(mAdapter); // Get the theme utils mTheme = new ThemeUtils(getActivity()); }
From source file:com.andrew.apollo.ui.fragments.ThemeFragment.java
/** * {@inheritDoc}/*from w w w . j a v a2 s . c om*/ */ @Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final Intent apolloThemeIntent = new Intent("com.andrew.apollo.THEMES"); apolloThemeIntent.addCategory("android.intent.category.DEFAULT"); mPackageManager = getSherlockActivity().getPackageManager(); mThemes = mPackageManager.queryIntentActivities(apolloThemeIntent, 0); mEntries = new String[mThemes.size() + 1]; mValues = new String[mThemes.size() + 1]; mThemePreview = new Drawable[mThemes.size() + 1]; // Default items mEntries[0] = getString(R.string.app_name); // mValues[0] = ThemeUtils.APOLLO_PACKAGE; mThemePreview[0] = getResources().getDrawable(R.drawable.theme_preview); for (int i = 0; i < mThemes.size(); i++) { mThemePackageName = mThemes.get(i).activityInfo.packageName.toString(); mThemeName = mThemes.get(i).loadLabel(mPackageManager).toString(); mEntries[i + 1] = mThemeName; mValues[i + 1] = mThemePackageName; // Theme resources try { mThemeResources = mPackageManager.getResourcesForApplication(mThemePackageName.toString()); } catch (final NameNotFoundException ignored) { } // Theme preview final int previewId = mThemeResources.getIdentifier("theme_preview", "drawable", //$NON-NLS-2$ mThemePackageName.toString()); if (previewId != 0) { mThemePreview[i + 1] = mThemeResources.getDrawable(previewId); } } // Initialize the Adapter mAdapter = new ThemesAdapter(getSherlockActivity(), R.layout.fragment_themes_base); // Bind the data mGridView.setAdapter(mAdapter); // Get the theme utils mTheme = new ThemeUtils(getSherlockActivity()); }
From source file:org.wso2.app.catalog.api.ApplicationManager.java
/** * Checks whether the DownloadManager is available on the device. * * @param context - Context of the calling activity. *///www .j ava2 s.c o m public boolean isDownloadManagerAvailable(Context context) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setClassName(resources.getString(R.string.android_download_manager_ui_resolver), resources.getString(R.string.android_download_manager_list_resolver)); return context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY) .size() > 0; }
From source file:gov.wa.wsdot.android.wsdot.service.FerriesSchedulesSyncService.java
@Override protected void onHandleIntent(Intent intent) { ContentResolver resolver = getContentResolver(); Cursor cursor = null;//from ww w . ja v a 2s. c o 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.boko.vimusic.ui.fragments.ThemeFragment.java
/** * {@inheritDoc}//from w w w .jav a 2 s. com */ @Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final Intent apolloThemeIntent = new Intent("com.boko.vimusic.THEMES"); apolloThemeIntent.addCategory("android.intent.category.DEFAULT"); mPackageManager = getActivity().getPackageManager(); mThemes = mPackageManager.queryIntentActivities(apolloThemeIntent, 0); mEntries = new String[mThemes.size() + 1]; mValues = new String[mThemes.size() + 1]; mThemePreview = new Drawable[mThemes.size() + 1]; // Default items mEntries[0] = getString(R.string.app_name); // mValues[0] = ThemeUtils.APOLLO_PACKAGE; mThemePreview[0] = getResources().getDrawable(R.drawable.theme_preview); for (int i = 0; i < mThemes.size(); i++) { mThemePackageName = mThemes.get(i).activityInfo.packageName.toString(); mThemeName = mThemes.get(i).loadLabel(mPackageManager).toString(); mEntries[i + 1] = mThemeName; mValues[i + 1] = mThemePackageName; // Theme resources try { mThemeResources = mPackageManager.getResourcesForApplication(mThemePackageName.toString()); } catch (final NameNotFoundException ignored) { } // Theme preview final int previewId = mThemeResources.getIdentifier("theme_preview", "drawable", //$NON-NLS-2$ mThemePackageName.toString()); if (previewId != 0) { mThemePreview[i + 1] = mThemeResources.getDrawable(previewId); } } // Initialize the Adapter mAdapter = new ThemesAdapter(getActivity(), R.layout.fragment_themes_base); // Bind the data mGridView.setAdapter(mAdapter); // Get the theme utils mTheme = new ThemeUtils(getActivity()); }
From source file:com.example.android.supportv7.media.SampleMediaRouterActivity.java
private Intent makePlayIntent(MediaItem item) { Intent intent = new Intent(MediaControlIntent.ACTION_PLAY); intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK); intent.setDataAndType(item.mUri, "video/mp4"); return intent; }
From source file:net.dahanne.spring.android.ch3.restful.example.recipeapp.RecipesList.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { // The data from the menu item. AdapterView.AdapterContextMenuInfo info; // Tries to get the position of the item in the ListView that was long-pressed. try {/*from w ww . ja va 2 s.com*/ // Casts the incoming data object into the type for AdapterView objects. info = (AdapterView.AdapterContextMenuInfo) menuInfo; } catch (ClassCastException e) { // If the menu object can't be cast, logs an error. Log.e(TAG, "bad menuInfo", e); return; } Intent intent = new Intent(null, Uri.withAppendedPath(getIntent().getData(), Integer.toString((int) info.id))); intent.addCategory(Intent.CATEGORY_ALTERNATIVE); menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0, new ComponentName(this, RecipesList.class), null, intent, 0, null); }
From source file:com.example.android.supportv7.media.SampleMediaRouterActivity.java
private Intent makeStatisticsIntent() { Intent intent = new Intent(SampleMediaRouteProvider.ACTION_GET_STATISTICS); intent.addCategory(SampleMediaRouteProvider.CATEGORY_SAMPLE_ROUTE); return intent; }