Search in sources :

Example 61 with Uri

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;
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) Uri(android.net.Uri)

Example 62 with Uri

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;
}
Also used : Cursor(android.database.Cursor) Uri(android.net.Uri)

Example 63 with Uri

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);
        }
    }
}
Also used : IntentFilter(android.content.IntentFilter) ActivityInfo(android.content.pm.ActivityInfo) Uri(android.net.Uri) SuppressLint(android.annotation.SuppressLint) ResolveInfo(android.content.pm.ResolveInfo) ComponentName(android.content.ComponentName) PatternMatcher(android.os.PatternMatcher)

Example 64 with Uri

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);
}
Also used : Uri(android.net.Uri) ContentResolver(android.content.ContentResolver)

Example 65 with Uri

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));
}
Also used : ShadowBitmap(org.robolectric.shadows.ShadowBitmap) Bitmap(android.graphics.Bitmap) Transition(com.bumptech.glide.request.transition.Transition) Uri(android.net.Uri) Test(org.junit.Test)

Aggregations

Uri (android.net.Uri)3406 Intent (android.content.Intent)732 Cursor (android.database.Cursor)466 ContentValues (android.content.ContentValues)349 File (java.io.File)339 IOException (java.io.IOException)254 ContentResolver (android.content.ContentResolver)242 ArrayList (java.util.ArrayList)209 Test (org.junit.Test)194 RemoteException (android.os.RemoteException)190 Bundle (android.os.Bundle)154 Bitmap (android.graphics.Bitmap)129 Context (android.content.Context)118 InputStream (java.io.InputStream)110 PendingIntent (android.app.PendingIntent)104 LargeTest (android.test.suitebuilder.annotation.LargeTest)97 View (android.view.View)95 FileNotFoundException (java.io.FileNotFoundException)94 Request (android.app.DownloadManager.Request)83 TextView (android.widget.TextView)73