use of android.net.Uri in project cordova-android-chromeview by thedracle.
the class ContactAccessorSdk5 method photoQuery.
/**
* Create a ContactField JSONObject
* @param contactId
* @return a JSONObject representing a ContactField
*/
private JSONObject photoQuery(Cursor cursor, String contactId) {
JSONObject photo = new JSONObject();
try {
photo.put("id", cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Photo._ID)));
photo.put("pref", false);
photo.put("type", "url");
Uri person = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, (new Long(contactId)));
Uri photoUri = Uri.withAppendedPath(person, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
photo.put("value", photoUri.toString());
} catch (JSONException e) {
Log.e(LOG_TAG, e.getMessage(), e);
}
return photo;
}
use of android.net.Uri in project cordova-android-chromeview by thedracle.
the class ContactAccessorSdk5 method remove.
@Override
public /**
* This method will remove a Contact from the database based on ID.
* @param id the unique ID of the contact to remove
*/
boolean remove(String id) {
int result = 0;
Cursor cursor = mApp.getActivity().getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, ContactsContract.Contacts._ID + " = ?", new String[] { id }, null);
if (cursor.getCount() == 1) {
cursor.moveToFirst();
String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey);
result = mApp.getActivity().getContentResolver().delete(uri, null, null);
} else {
Log.d(LOG_TAG, "Could not find contact with ID");
}
return (result > 0) ? true : false;
}
use of android.net.Uri in project VirtualApp by asLody.
the class ResolverActivity method onIntentSelected.
protected void onIntentSelected(ResolveInfo ri, Intent intent, boolean alwaysCheck) {
if (mAlwaysUseOption && mAdapter.mOrigResolveList != null) {
// Build a reasonable intent filter, based on what matched.
IntentFilter filter = new IntentFilter();
if (intent.getAction() != null) {
filter.addAction(intent.getAction());
}
Set<String> categories = intent.getCategories();
if (categories != null) {
for (String cat : categories) {
filter.addCategory(cat);
}
}
filter.addCategory(Intent.CATEGORY_DEFAULT);
int cat = ri.match & IntentFilter.MATCH_CATEGORY_MASK;
Uri data = intent.getData();
if (cat == IntentFilter.MATCH_CATEGORY_TYPE) {
String mimeType = intent.resolveType(this);
if (mimeType != null) {
try {
filter.addDataType(mimeType);
} catch (IntentFilter.MalformedMimeTypeException e) {
VLog.w("ResolverActivity", "mimeType\n" + VLog.getStackTraceString(e));
filter = null;
}
}
}
if (data != null && data.getScheme() != null) {
// or "content:" schemes (see IntentFilter for the reason).
if (cat != IntentFilter.MATCH_CATEGORY_TYPE || (!"file".equals(data.getScheme()) && !"content".equals(data.getScheme()))) {
filter.addDataScheme(data.getScheme());
if (Build.VERSION.SDK_INT >= 19) {
// Look through the resolved filter to determine which part
// of it matched the original Intent.
Iterator<PatternMatcher> pIt = ri.filter.schemeSpecificPartsIterator();
if (pIt != null) {
String ssp = data.getSchemeSpecificPart();
while (ssp != null && pIt.hasNext()) {
PatternMatcher p = pIt.next();
if (p.match(ssp)) {
filter.addDataSchemeSpecificPart(p.getPath(), p.getType());
break;
}
}
}
Iterator<IntentFilter.AuthorityEntry> aIt = ri.filter.authoritiesIterator();
if (aIt != null) {
while (aIt.hasNext()) {
IntentFilter.AuthorityEntry a = aIt.next();
if (a.match(data) >= 0) {
int port = a.getPort();
filter.addDataAuthority(a.getHost(), port >= 0 ? Integer.toString(port) : null);
break;
}
}
}
pIt = ri.filter.pathsIterator();
if (pIt != null) {
String path = data.getPath();
while (path != null && pIt.hasNext()) {
PatternMatcher p = pIt.next();
if (p.match(path)) {
filter.addDataPath(p.getPath(), p.getType());
break;
}
}
}
}
}
}
if (filter != null) {
final int N = mAdapter.mOrigResolveList.size();
ComponentName[] set = new ComponentName[N];
int bestMatch = 0;
for (int i = 0; i < N; i++) {
ResolveInfo r = mAdapter.mOrigResolveList.get(i);
set[i] = new ComponentName(r.activityInfo.packageName, r.activityInfo.name);
if (r.match > bestMatch)
bestMatch = r.match;
}
if (alwaysCheck) {
getPackageManager().addPreferredActivity(filter, bestMatch, set, intent.getComponent());
} else {
try {
Reflect.on(VClientImpl.get().getCurrentApplication().getPackageManager()).call("setLastChosenActivity", intent, intent.resolveTypeIfNeeded(getContentResolver()), PackageManager.MATCH_DEFAULT_ONLY, filter, bestMatch, intent.getComponent());
} catch (Exception re) {
VLog.d(TAG, "Error calling setLastChosenActivity\n" + VLog.getStackTraceString(re));
}
}
}
}
if (intent != null) {
ActivityInfo info = VirtualCore.get().resolveActivityInfo(intent, mLaunchedFromUid);
if (info == null) {
//外面的
startActivity(intent);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// startActivity(intent);//, mRequestCode, mOptions);
// }else{
// startActivity(intent);//, mRequestCode);
// }
} else {
VActivityManager.get().startActivity(intent, info, null, mOptions, mResultWho, mRequestCode, mLaunchedFromUid);
}
}
}
use of android.net.Uri in project VirtualApp by asLody.
the class ProviderCall method call.
public static Bundle call(String authority, Context context, String methodName, String arg, Bundle bundle) {
Uri uri = Uri.parse("content://" + authority);
ContentResolver contentResolver = context.getContentResolver();
return contentResolver.call(uri, methodName, arg, bundle);
}
use of android.net.Uri in project glide by bumptech.
the class GlideTest method testToBytesOption.
@Test
public void testToBytesOption() {
Uri uri = Uri.parse("content://something/else");
mockUri(uri);
requestManager.as(byte[].class).apply(decodeTypeOf(Bitmap.class)).load(uri).into(target);
verify(target).onResourceReady(isA(byte[].class), isA(Transition.class));
}
Aggregations