List of usage examples for android.content ContentUris parseId
public static long parseId(Uri contentUri)
From source file:Main.java
public static String getThumbnailPathFromURI(Uri contentUri, ContentResolver content_resolver) { String uri = ""; Cursor cursor = MediaStore.Images.Thumbnails.queryMiniThumbnail(content_resolver, ContentUris.parseId(contentUri), MediaStore.Images.Thumbnails.MINI_KIND, null); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst();//**EDIT** uri = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA)); }//from w ww.jav a 2s .c o m return uri; }
From source file:Main.java
/** * Take an environment URI (one that identifies an environment) and produce an * event URI./*w w w . j a v a 2 s . c o m*/ * * That this is needed is tragic. * * @param environmentURI * the {@link Uri} returned by an environment operation. * @return a {@link Uri} to which insertions can be dispatched. */ public static Uri getEventURI(Uri environmentURI) { return environmentURI.buildUpon().path("/events/" + ContentUris.parseId(environmentURI) + "/").build(); }
From source file:Main.java
/** * Transforms the given Uri and returns a Lookup-Uri that represents the contact. * For legacy contacts, a raw-contact lookup is performed. An {@link IllegalArgumentException} * can be thrown if the URI is null or the authority is not recognized. * * Do not call from the UI thread./*from ww w. j a va2s.c om*/ */ @SuppressWarnings("deprecation") public static Uri ensureIsContactUri(final ContentResolver resolver, final Uri uri) throws IllegalArgumentException { if (uri == null) throw new IllegalArgumentException("uri must not be null"); final String authority = uri.getAuthority(); // Current Style Uri? if (ContactsContract.AUTHORITY.equals(authority)) { final String type = resolver.getType(uri); // Contact-Uri? Good, return it if (ContactsContract.Contacts.CONTENT_ITEM_TYPE.equals(type)) { return uri; } // RawContact-Uri? Transform it to ContactUri if (RawContacts.CONTENT_ITEM_TYPE.equals(type)) { final long rawContactId = ContentUris.parseId(uri); return RawContacts.getContactLookupUri(resolver, ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId)); } // Anything else? We don't know what this is throw new IllegalArgumentException("uri format is unknown"); } // Legacy Style? Convert to RawContact final String OBSOLETE_AUTHORITY = Contacts.AUTHORITY; if (OBSOLETE_AUTHORITY.equals(authority)) { // Legacy Format. Convert to RawContact-Uri and then lookup the contact final long rawContactId = ContentUris.parseId(uri); return RawContacts.getContactLookupUri(resolver, ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId)); } throw new IllegalArgumentException("uri authority is unknown"); }
From source file:edu.mit.mobile.android.locast.data.Itinerary.java
public static Uri getCastsUri(Uri itinerary) { if (ContentUris.parseId(itinerary) == -1) { throw new IllegalArgumentException(itinerary + " does not appear to be an itinerary item URI"); }/*from w ww . j a v a2 s . c o m*/ return Uri.withAppendedPath(itinerary, Cast.PATH); }
From source file:org.isoron.uhabits.ShowHabitActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Uri data = getIntent().getData();/*www.ja v a 2s . co m*/ habit = Habit.get(ContentUris.parseId(data)); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setTitle(habit.name); if (android.os.Build.VERSION.SDK_INT >= 21) actionBar.setBackgroundDrawable(new ColorDrawable(habit.color)); } setContentView(R.layout.show_habit_activity); fragment = (ShowHabitFragment) getFragmentManager().findFragmentById(R.id.fragment2); receiver = new Receiver(); localBroadcastManager = LocalBroadcastManager.getInstance(this); localBroadcastManager.registerReceiver(receiver, new IntentFilter(MainActivity.ACTION_REFRESH)); }
From source file:fr.eoidb.activity.ItemInfoActivity.java
/** Called when the activity is first created. */ @Override/*from w w w. java 2 s . c o m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.item_info); setActionBarInderterminate(true); itemId = (int) ContentUris.parseId(getIntent().getData()); initOrRestart(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(false); if (findViewById(R.id.ITEM_ICON_LAYOUT) != null) { findViewById(R.id.ITEM_ICON_LAYOUT).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (isItemIconExpended) { LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 150, getResources().getDisplayMetrics())); v.setLayoutParams(layoutParams); isItemIconExpended = false; } else { LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics())); v.setLayoutParams(layoutParams); isItemIconExpended = true; } } }); } }
From source file:com.ksk.droidbatterybooster.provider.PowerSchedule.java
public static long getId(Uri contentUri) { return ContentUris.parseId(contentUri); }
From source file:fr.eoit.activity.LocationPricesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { pricesUpdated = savedInstanceState.getBoolean("pricesUpdated"); itemId = savedInstanceState.getInt("itemId"); }// ww w. j av a 2s. com setContentView(R.layout.location_prices); itemId = (int) ContentUris.parseId(getIntent().getData()); // The names of the cursor columns to display in the view, initialized to the title column String[] dataColumns = { Station.COLUMN_NAME_STATION_TYPE_ID, Station.COLUMN_NAME_NAME, Region.COLUMN_NAME_NAME_ALIAS, Prices.COLUMN_NAME_BUY_PRICE, Prices.COLUMN_NAME_BUY_VOLUME, Prices.COLUMN_NAME_SELL_PRICE, Prices.COLUMN_NAME_SELL_VOLUME }; // The view IDs that will display the cursor columns, initialized to the TextView in // noteslist_item.xml int[] viewIDs = { R.id.station_icon, R.id.station_name, R.id.location_name, R.id.buy_price, R.id.buy_volume, R.id.sell_price, R.id.sell_volume }; // Creates the backing adapter for the ListView. adapter = new SimpleCursorAdapter(this, R.layout.price_station_row, null, dataColumns, viewIDs, SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); adapter.setViewBinder(new StationListViewBinder()); ListView listView = (ListView) findViewById(R.id.location_list); //listView.setOnItemClickListener(new ItemOnItemListClickListener()); // Sets the ListView's adapter to be the cursor adapter that was just created. listView.setAdapter(adapter); initOrRestart(); }
From source file:com.ksk.droidbatterybooster.provider.OptimalMode.java
public static long getModeId(Uri contentUri) { return ContentUris.parseId(contentUri); }
From source file:mobisocial.musubi.ui.ViewProfileActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tabbed); Intent intent = getIntent();// ww w . jav a 2 s .co m Long id = null; // intent from address book Intent is = getIntent(); Uri data = getIntent().getData(); String type = getIntent().getType(); if (data != null) { if (type != null && type.equals(MusubiContentProvider.getType(Provided.IDENTITIES_ID))) { id = ContentUris.parseId(data); } else if (data.getAuthority().equals(ContactsContract.AUTHORITY)) { // intent sent from address book have null type long rawId = ContentUris.parseId(data); id = getMusubiId(rawId); } } if (id == null) { id = intent.getLongExtra(PROFILE_ID, -1); } setTitle("Relationships"); mLabels.add("Profile"); mFragments.add(ViewProfileFragment.newInstance(id)); SQLiteOpenHelper helper = App.getDatabaseSource(this); IdentitiesManager im = new IdentitiesManager(helper); MIdentity identity = im.getIdentityForId(id); if (identity == null) { UsageMetrics.getUsageMetrics(this) .report(new Throwable("Invalid identity " + id + " passed tp ViewProfileActivity")); finish(); return; } FeedManager fm = new FeedManager(helper); mFeedIds = fm.getFeedsForIdentityId(id); setTitle(identity.name_); if (!identity.owned_) { mLabels.add("Conversations"); Bundle args = new Bundle(); args.putLong(ConversationsFragment.ARG_IDENTITY_ID, identity.id_); ConversationsFragment f = new ConversationsFragment(); f.setArguments(args); mFragments.add(f); } else { setTitle("Your profile"); } PagerAdapter adapter = new ViewFragmentAdapter(getSupportFragmentManager(), mFragments, mLabels); mViewPager = (ViewPager) findViewById(R.id.feed_pager); mViewPager.setAdapter(adapter); //Bind the tab indicator to the adapter TabPageIndicator tabIndicator = (TabPageIndicator) findViewById(R.id.feed_titles); tabIndicator.setViewPager(mViewPager); }