Java Code Examples for android.net.Uri

The following are top voted examples for showing how to use android.net.Uri. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: MyFlightbookAndroid   File: ActMFBForm.java   View source code 6 votes vote down vote up
@Override
protected Boolean doInBackground(String... params) {
    String szFilename = params[0];
    if (szFilename == null || szFilename.length() == 0) {
        Log.e(MFBConstants.LOG_TAG, "No filename passed back!!!");
        return false;
    }

    // Add the image/video to the gallery if necessary (i.e., if from the camera)
    if (fAddToGallery) {
        File f = new File(szFilename);
        Uri uriSource = FileProvider.getUriForFile(ActMFBForm.this.getContext(), "com.example.android.fileprovider", f);
        ActMFBForm.this.getActivity().sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uriSource));
    }

    GallerySource gs = (GallerySource) ActMFBForm.this;
    mfbii = new MFBImageInfo(gs.getDestination());
    return mfbii.initFromCamera(szFilename, fGeoTag ? MFBLocation.LastSeenLoc() : null, m_fVideo, fDeleteFileWhenDone);
}
 
Example 2
Project: LaunchEnr   File: LauncherProvider.java   View source code 6 votes vote down vote up
@Override
public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {
    createDbIfNotExists();
    SqlArguments args = new SqlArguments(uri, selection, selectionArgs);

    SQLiteDatabase db = mOpenHelper.getWritableDatabase();

    if (Binder.getCallingPid() != Process.myPid()
            && Favorites.TABLE_NAME.equalsIgnoreCase(args.table)) {
        mOpenHelper.removeGhostWidgets(mOpenHelper.getWritableDatabase());
    }
    int count = db.delete(args.table, args.where, args.args);
    if (count > 0) {
        notifyListeners();
        reloadLauncherIfExternal();
    }
    return count;
}
 
Example 3
Project: LQRWeChat   File: MyApp.java   View source code 6 votes vote down vote up
/**
 * 初始化仿微信控件ImagePicker
 */
private void initImagePicker() {
    ImagePicker imagePicker = ImagePicker.getInstance();
    imagePicker.setImageLoader(new ImageLoader() {
        @Override
        public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
            Glide.with(getContext()).load(Uri.parse("file://" + path).toString()).centerCrop().into(imageView);
        }

        @Override
        public void clearMemoryCache() {

        }
    });   //设置图片加载器
    imagePicker.setShowCamera(true);  //显示拍照按钮
    imagePicker.setCrop(true);        //允许裁剪(单选才有效)
    imagePicker.setSaveRectangle(true); //是否按矩形区域保存
    imagePicker.setSelectLimit(9);    //选中数量限制
    imagePicker.setStyle(CropImageView.Style.RECTANGLE);  //裁剪框的形状
    imagePicker.setFocusWidth(800);   //裁剪框的宽度。单位像素(圆形自动取宽高最小值)
    imagePicker.setFocusHeight(800);  //裁剪框的高度。单位像素(圆形自动取宽高最小值)
    imagePicker.setOutPutX(1000);//保存文件的宽度。单位像素
    imagePicker.setOutPutY(1000);//保存文件的高度。单位像素
}
 
Example 4
Project: rongyunDemo   File: ConversationActivity.java   View source code 6 votes vote down vote up
/**
 * 加载会话页面 ConversationFragmentEx 继承自 ConversationFragment
 *
 * @param mConversationType 会话类型
 * @param mTargetId         会话 Id
 */
private void enterFragment(Conversation.ConversationType mConversationType, String mTargetId) {

    fragment = new ConversationFragmentEx();

    Uri uri = Uri.parse("rong://" + getApplicationInfo().packageName).buildUpon()
              .appendPath("conversation").appendPath(mConversationType.getName().toLowerCase())
              .appendQueryParameter("targetId", mTargetId).build();

    fragment.setUri(uri);

    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    //xxx 为你要加载的 id
    transaction.add(R.id.rong_content, fragment);
    transaction.commitAllowingStateLoss();
}
 
Example 5
Project: siiMobilityAppKit   File: Calendar.java   View source code 6 votes vote down vote up
@TargetApi(14)
private void openCalendar(JSONArray args) {
  try {
    final Long millis = args.getJSONObject(0).optLong("date");

    cordova.getThreadPool().execute(new Runnable() {
      @Override
      public void run() {
        final Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon().appendPath("time");
        ContentUris.appendId(builder, millis);

        final Intent intent = new Intent(Intent.ACTION_VIEW).setData(builder.build());
        Calendar.this.cordova.startActivityForResult(Calendar.this, intent, RESULT_CODE_OPENCAL);

        callback.success();
      }
    });
  } catch (JSONException e) {
    System.err.println("Exception: " + e.getMessage());
    callback.error(e.getMessage());
  }
}
 
Example 6
Project: robird-reborn   File: AccountModel.java   View source code 6 votes vote down vote up
public Observable<Account> add(final AccessToken accessToken) {
    ContentValues values = new ContentValues();

    values.put(AccountContract.TOKEN, accessToken.getToken());
    values.put(AccountContract.TOKEN_SECRET, accessToken.getTokenSecret());
    values.put(AccountContract.SCREEN_NAME, accessToken.getScreenName());
    values.put(AccountContract.USER_ID, accessToken.getUserId());

    return mSqlBriteContentProvider
            .insert(AccountContract.CONTENT_URI, values)
            .flatMap(new Func1<Uri, Observable<SqlBriteContentProvider.Query>>() {
                @Override
                public Observable<SqlBriteContentProvider.Query> call(Uri uri) {
                    return mSqlBriteContentProvider
                            .query(uri, AccountContract.PROJECTION,
                                    null, null, null, false);
                }
            })
            .map(MapFunctions.ACCOUNT)
            .take(1);
}
 
Example 7
Project: streaminglib   File: RtspSession.java   View source code 6 votes vote down vote up
/**
 * Looks for the base URI
 * <p>
 * https://tools.ietf.org/html/rfc2326#appendix-C.1.1
 *
 * @param res RtspResponse
 * @return Base URI
 */
Uri extractBaseUri(RtspRequest req, RtspResponse res) throws URISyntaxException {
    Uri baseUri = null;

    // 1. The RTSP Content-Base field
    String contentBase = res.getContentBase();
    if (contentBase != null) baseUri = Uri.parse(res.getContentBase());

    // 2. The RTSP Content-Location field
    String contentLocation = res.getContentLocation();
    if (baseUri == null && contentLocation != null) {
        baseUri = Uri.parse(res.getContentLocation());
    }

    // 3. The RTSP request URL
    if (baseUri == null) baseUri = req.getUri();

    return baseUri;
}
 
Example 8
Project: alerta-fraude   File: CordovaResourceApi.java   View source code 6 votes vote down vote up
/**
 * Returns a File that points to the resource, or null if the resource
 * is not on the local filesystem.
 */
public File mapUriToFile(Uri uri) {
    assertBackgroundThread();
    switch (getUriType(uri)) {
        case URI_TYPE_FILE:
            return new File(uri.getPath());
        case URI_TYPE_CONTENT: {
            Cursor cursor = contentResolver.query(uri, LOCAL_FILE_PROJECTION, null, null, null);
            if (cursor != null) {
                try {
                    int columnIndex = cursor.getColumnIndex(LOCAL_FILE_PROJECTION[0]);
                    if (columnIndex != -1 && cursor.getCount() > 0) {
                        cursor.moveToFirst();
                        String realPath = cursor.getString(columnIndex);
                        if (realPath != null) {
                            return new File(realPath);
                        }
                    }
                } finally {
                    cursor.close();
                }
            }
        }
    }
    return null;
}
 
Example 9
Project: GCSApp   File: CreateACActivity.java   View source code 6 votes vote down vote up
public void takePicture() {
    try {
        mPhotoPath = sdcardPath + "/icon.png";
        mPhotoFile = new File(mPhotoPath);
        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        if (Build.VERSION.SDK_INT >= 23) {
            Uri uri = FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".provider", mPhotoFile);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);

        }else {

            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mPhotoFile));
        }
        startActivityForResult(intent, 1);
    } catch (Exception e) {
    }
}
 
Example 10
Project: BaseCore   File: LocalShareUtils.java   View source code 6 votes vote down vote up
/**
 * 分享单张图片至所有第三方软件
 */
public static void ShareSingleImage(Context context, File file) {
    Uri imageUri;

    if (Build.VERSION.SDK_INT >= 24) {
        imageUri = FileProvider.getUriForFile(context,"com.hzecool.common.fileProvider", file);
    } else {
        imageUri = Uri.fromFile(file);
    }


    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
    shareIntent.setType("image/*");
    context.startActivity(Intent.createChooser(shareIntent, "分享到"));

}
 
Example 11
Project: GitHub   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 12
Project: media-picker-android   File: GalleryPicker.java   View source code 6 votes vote down vote up
@Override
public Uri start(Activity activity, MediaResult mediaResult, PhotoParams photoParams) {
    Log.d(getClass().getName(), "pick gallery");

    if (hasPicker(activity)) {
        if (FeatureUtils.isSdAvailable()) {
            activity.startActivityForResult(intent, mediaResult.getRequestCode());

            return createExternalUri(activity.getApplicationContext());
        }else {
            mediaResultListener.onPickMediaResult(mediaResult, activity.getString(R.string.error_please_plug_sd_card));

        }

    } else {
        mediaResultListener.onPickMediaResult(mediaResult, photoParams.getNoGalleryMsg());
    }

    return Uri.EMPTY;
}
 
Example 13
Project: boohee_v5.6   File: MediaStoreUtils.java   View source code 6 votes vote down vote up
public static String getRealPathFromUri(Context context, Uri uri) {
    if (uri != null) {
        Helper.showLog(TAG, uri.toString());
    }
    String realPath = null;
    Cursor cursor = null;
    try {
        cursor = context.getContentResolver().query(uri, new String[]{"_data"}, null, null,
                null);
        if (cursor != null) {
            int column_index = cursor.getColumnIndexOrThrow("_data");
            cursor.moveToFirst();
            realPath = cursor.getString(column_index);
        }
        Helper.showLog(TAG + "real path", realPath);
        return realPath;
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}
 
Example 14
Project: Perfect-Day   File: TaskItemsContentProvider.java   View source code 6 votes vote down vote up
@Nullable
@Override
public String getType(@NonNull Uri uri) {
    int match = sUriMATCHER.match(uri);

    switch (match) {
        case ITEM_TASKS:
            return "vnd.android.cursor.dir" + "/" + TaskItemsContract.AUTHORITY + "/" + TaskItemsContract.PATH_TASK_ITEMS;
        case ITEM_TASKS_WITH_ID:
            return "vnd.android.cursor.item" + "/" + TaskItemsContract.AUTHORITY + "/" + TaskItemsContract.PATH_TASK_ITEMS;
        case ITEM_TASKS_TODAY:
            return "vnd.android.cursor.dir" + "/" + TaskItemsContract.AUTHORITY + "/" + TaskItemsContract.PATH_TASK_ITEMS + "/" + COLUMN_NAME_IS_TODAY;
        default:
            throw new UnsupportedOperationException("Unknown uri: " + uri);
    }
}
 
Example 15
Project: localcloud_fe   File: CameraLauncher.java   View source code 6 votes vote down vote up
/**
 * Create entry in media store for image
 *
 * @return uri
 */
private Uri getUriFromMediaStore() {
    ContentValues values = new ContentValues();
    values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
    Uri uri;
    try {
        uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
    } catch (RuntimeException e) {
        LOG.d(LOG_TAG, "Can't write to external media storage.");
        try {
            uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
        } catch (RuntimeException ex) {
            LOG.d(LOG_TAG, "Can't write to internal media storage.");
            return null;
        }
    }
    return uri;
}
 
Example 16
Project: Android-Music-Player   File: genersBtns.java   View source code 6 votes vote down vote up
ArrayList<Uri> getAlbumsFiles(){

        String searchString = MediaStore.Audio.Genres.Members.IS_MUSIC+"=?";
        String[] searchPram = new String[]{"1"};
        String[] cols = new String[] {  MediaStore.Audio.Genres.Members.DATA };
        Cursor cursor = Ui.ef.getBaseContext().getContentResolver().query(MediaStore.Audio.Genres.Members.getContentUri("external", Long.parseLong(data[1])),cols, searchString,searchPram, MediaStore.Audio.Media.TITLE +" COLLATE NOCASE ASC");


        ArrayList<Uri> files = new ArrayList<Uri>();
        for (int i = 0; i < cursor.getCount(); i++) {
            cursor.moveToNext();
            File file = new File(cursor.getString(0));
            Uri uri = Uri.fromFile(file);
            files.add(uri);
        }
        cursor.close();

        return  files;

    }
 
Example 17
Project: GoSCELE   File: OpenOtherAppUtil.java   View source code 6 votes vote down vote up
public static void openLink(Context context, String url) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));
    PackageManager packageManager = context.getPackageManager();
    List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
    String packageNameToHide = context.getPackageName();
    ArrayList<Intent> targetIntents = new ArrayList<>();
    for (ResolveInfo currentInfo : activities) {
        String packageName = currentInfo.activityInfo.packageName;
        if (!packageNameToHide.equals(packageName)) {
            Intent targetIntent = new Intent(Intent.ACTION_VIEW);
            targetIntent.setData(Uri.parse(url));
            targetIntent.setPackage(packageName);
            targetIntents.add(targetIntent);
        }
    }
    Intent chooserIntent = Intent.createChooser(targetIntents.remove(0), "Open with");
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetIntents.toArray(new Parcelable[]{}));
    context.startActivity(chooserIntent);
}
 
Example 18
Project: linkedout_procon   File: StudentRegisterActivity.java   View source code 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK && requestCode == pic.SELECT_IMAGE) {
        Uri selectedImage = data.getData();
        String path = pic.getPath(selectedImage, this);
        pic.setPath(path);
        Bitmap bitmapImage = BitmapFactory.decodeFile(path);
        pic.setBitmap(bitmapImage);
        int rotateAngle = pic.getPhotoOrientation(StudentRegisterActivity.this, selectedImage, path);
        pic.setBitmap(pic.rotateBitmap(rotateAngle));
        ImageView image = (ImageView) findViewById(R.id.thumbnail);
        image.setImageBitmap(pic.getResizedBitmap());
    }
}
 
Example 19
Project: tvConnect_android   File: ResultHandler.java   View source code 5 votes vote down vote up
final void sendMMSFromUri(String uri, String subject, String body) {
  Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
  // The Messaging app needs to see a valid subject or else it will treat this an an SMS.
  if (subject == null || subject.isEmpty()) {
    putExtra(intent, "subject", activity.getString(R.string.app_name));
  } else {
    putExtra(intent, "subject", subject);
  }
  putExtra(intent, "sms_body", body);
  intent.putExtra("compose_mode", true);
  launchIntent(intent);
}
 
Example 20
Project: android-instant-apps   File: MainActivityTest.java   View source code 5 votes vote down vote up
@Override
protected Intent getActivityIntent() {
    return new Intent()
            .addCategory(Intent.CATEGORY_BROWSABLE)
            .setAction(Intent.ACTION_VIEW)
            .setData(Uri.parse("https://multi-feature.instantappsample.com/main"));
}
 
Example 21
Project: VirtualHook   File: ContentProviderCompat.java   View source code 5 votes vote down vote up
public static Bundle call(Context context, Uri uri, String method, String arg, Bundle extras) {
    if (VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return context.getContentResolver().call(uri, method, arg, extras);
    }
    ContentProviderClient client = crazyAcquireContentProvider(context, uri);
    Bundle res = null;
    try {
        res = client.call(method, arg, extras);
    } catch (RemoteException e) {
        e.printStackTrace();
    } finally {
        releaseQuietly(client);
    }
    return res;
}
 
Example 22
Project: alerta-fraude   File: PluginManager.java   View source code 5 votes vote down vote up
Uri remapUri(Uri uri) {
    for (CordovaPlugin plugin : this.pluginMap.values()) {
        if (plugin != null) {
            Uri ret = plugin.remapUri(uri);
            if (ret != null) {
                return ret;
            }
        }
    }
    return null;
}
 
Example 23
Project: DroidPlugin   File: AbstractContentProviderStub.java   View source code 5 votes vote down vote up
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
    String targetAuthority = uri.getQueryParameter(Env.EXTRA_TARGET_AUTHORITY);
    if (!TextUtils.isEmpty(targetAuthority) && !TextUtils.equals(targetAuthority, uri.getAuthority())) {
        ContentProviderClient client = getContentProviderClient(targetAuthority);
        try {
            return client.delete(buildNewUri(uri, targetAuthority), selection, selectionArgs);
        } catch (RemoteException e) {
            handleExpcetion(e);
        }
    }
    return 0;
}
 
Example 24
Project: GitHub   File: GlideTest.java   View source code 5 votes vote down vote up
@Test
public void testReceivesGifBytes() throws IOException {
  String fakeUri = "content://fake";
  InputStream testGifData = openGif();
  mockUri(Uri.parse(fakeUri), testGifData);

  requestManager.as(byte[].class).apply(decodeTypeOf(GifDrawable.class)).load(fakeUri)
      .into(target);

  verify(target).onResourceReady(isA(byte[].class), isA(Transition.class));
}
 
Example 25
Project: GitHub   File: DeviceUtils.java   View source code 5 votes vote down vote up
/**
 * 卸载软件
 *
 * @param context
 * @param packageName
 */
public static void uninstallApk(Context context, String packageName) {
    if (isPackageExist(context, packageName)) {
        Uri packageURI = Uri.parse("package:" + packageName);
        Intent uninstallIntent = new Intent(Intent.ACTION_DELETE,
                packageURI);
        context.startActivity(uninstallIntent);
    }
}
 
Example 26
Project: sctalk   File: UpdateDetection.java   View source code 5 votes vote down vote up
/**
 * 安装apk
 */
private void installApk(){
    File apkfile = new File(saveFileName);
    if (!apkfile.exists()) {
        return;
    }
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setDataAndType(Uri.parse("file://" + apkfile.toString()), "application/vnd.android.package-archive");
    mContext.startActivity(i);
}
 
Example 27
Project: boohee_v5.6   File: Util.java   View source code 5 votes vote down vote up
private static void a(Context context, String str, String str2, String str3) {
    Intent intent = new Intent();
    intent.setComponent(new ComponentName(str, str2));
    intent.setAction("android.intent.action.VIEW");
    intent.addFlags(1073741824);
    intent.addFlags(268435456);
    intent.setData(Uri.parse(str3));
    context.startActivity(intent);
}
 
Example 28
Project: baselibrary-master   File: BaseFragmentActivity.java   View source code 5 votes vote down vote up
/**
 * 淡入淡出加载图片
 *
 * @param imageview        图片控件
 * @param uri              图片uri
 * @param errorResId       加载失败时显示的图片资源id
 * @param placeholderResId 加载时的占位图资源id
 */
public void setImageUri(@NonNull ImageView imageview, Uri uri, @DrawableRes int errorResId, @DrawableRes int placeholderResId) {
    Glide.with(mContext)
            .load(uri)
            .crossFade()
            .error(errorResId)
            .placeholder(placeholderResId)
            .into(imageview);
}
 
Example 29
Project: microMathematics   File: AdapterDocuments.java   View source code 5 votes vote down vote up
public static Uri getParent(Uri u)
{
    if (u == null)
        return null;
    final List<String> paths = u.getPathSegments();
    final int n = paths.size();
    if (n < 4)
        return null;
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < n - 1; i++)
    {
        sb.append("/");
        sb.append(paths.get(i));
    }
    if (n == 4)
    {
        String last = paths.get(n - 1);
        int col_pos = last.lastIndexOf(':');
        if (!(col_pos <= 0 || col_pos == last.length() - 1))
        {
            sb.append("/");
            sb.append(last.substring(0, col_pos + 1));
            String subpath = last.substring(col_pos + 1);
            subpath = Uri.decode(subpath);
            int sl_pos = subpath.lastIndexOf(SLC);
            if (sl_pos > 0)
            {
                subpath = subpath.substring(0, sl_pos);
                sb.append(Uri.encode(subpath));
            }
        }
        return u.buildUpon().encodedPath(sb.toString()).build();
    }
    return null;
}
 
Example 30
Project: Android-UtilCode   File: ClipboardUtils.java   View source code 5 votes vote down vote up
/**
 * 获取剪贴板的uri
 *
 * @return 剪贴板的uri
 */
public static Uri getUri() {
    ClipboardManager clipboard = (ClipboardManager) Utils.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null && clip.getItemCount() > 0) {
        return clip.getItemAt(0).getUri();
    }
    return null;
}
 
Example 31
Project: sealtalk-android-master   File: DiscussionDetailActivity.java   View source code 5 votes vote down vote up
@Override
public void onSuccess(int requestCode, Object result) {
    switch (requestCode) {
        case FIND_USER_INFO:
            GetUserInfosResponse response = (GetUserInfosResponse) result;
            if (response.getCode() == 200) {
                List<GetUserInfosResponse.ResultEntity> infos = response.getResult();
                memberList.clear();
                for (GetUserInfosResponse.ResultEntity g : infos) {
                    memberList.add(new UserInfo(g.getId(), g.getNickname(), Uri.parse(g.getPortraitUri())));
                }
                String loginId = getSharedPreferences("config", MODE_PRIVATE).getString(SealConst.SEALTALK_LOGIN_ID, "");
                if (loginId.equals(createId)) {
                    isCreated = true;
                }
                if (memberList != null && memberList.size() > 1) {
                    if (adapter == null) {
                        adapter = new GridAdapter(mContext, memberList);
                        mGridView.setAdapter(adapter);
                    } else {
                        adapter.updateListView(memberList);
                    }
                }
                LoadDialog.dismiss(mContext);
            }
            break;
    }
}
 
Example 32
Project: chuck   File: ChuckContentProvider.java   View source code 5 votes vote down vote up
@Override
public void attachInfo(Context context, ProviderInfo info) {
    super.attachInfo(context, info);
    TRANSACTION_URI = Uri.parse("content://" + info.authority + "/transaction");
    matcher.addURI(info.authority, "transaction/#", TRANSACTION);
    matcher.addURI(info.authority, "transaction", TRANSACTIONS);
}
 
Example 33
Project: android-dev-challenge   File: WeatherProvider.java   View source code 5 votes vote down vote up
/**
 * Deletes data at a given URI with optional arguments for more fine tuned deletions.
 *
 * @param uri           The full URI to query
 * @param selection     An optional restriction to apply to rows when deleting.
 * @param selectionArgs Used in conjunction with the selection statement
 * @return The number of rows deleted
 */
@Override
public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {

    /* Users of the delete method will expect the number of rows deleted to be returned. */
    int numRowsDeleted;

    /*
     * If we pass null as the selection to SQLiteDatabase#delete, our entire table will be
     * deleted. However, if we do pass null and delete all of the rows in the table, we won't
     * know how many rows were deleted. According to the documentation for SQLiteDatabase,
     * passing "1" for the selection will delete all rows and return the number of rows
     * deleted, which is what the caller of this method expects.
     */
    if (null == selection) selection = "1";

    switch (sUriMatcher.match(uri)) {

        case CODE_WEATHER:
            numRowsDeleted = mOpenHelper.getWritableDatabase().delete(
                    WeatherContract.WeatherEntry.TABLE_NAME,
                    selection,
                    selectionArgs);

            break;

        default:
            throw new UnsupportedOperationException("Unknown uri: " + uri);
    }

    /* If we actually deleted any rows, notify that a change has occurred to this URI */
    if (numRowsDeleted != 0) {
        getContext().getContentResolver().notifyChange(uri, null);
    }

    return numRowsDeleted;
}
 
Example 34
Project: simple-share-android   File: DocumentsContract.java   View source code 5 votes vote down vote up
/**
 * Test if the given URI represents a {@link Document} backed by a
 * {@link DocumentsProvider}.
 *
 * @see #buildDocumentUri(String, String)
 * @see #buildDocumentUriUsingTree(Uri, String)
 */
public static boolean isDocumentUri(Context context, @Nullable Uri uri) {
    if (isContentUri(uri) && isDocumentsProvider(context, uri.getAuthority())) {
        final List<String> paths = uri.getPathSegments();
        if (paths.size() == 2) {
            return PATH_DOCUMENT.equals(paths.get(0));
        } else if (paths.size() == 4) {
            return PATH_TREE.equals(paths.get(0)) && PATH_DOCUMENT.equals(paths.get(2));
        }
    }
    return false;
}
 
Example 35
Project: RX_Demo   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_CODE_CHOOSE && resultCode == RESULT_OK) {
        List<Uri> mSelected = Matisse.obtainResult(data);
        Log.i("Matisse", "mSelected: " + mSelected);
    }
}
 
Example 36
Project: BookyMcBookface   File: ReaderActivity.java   View source code 5 votes vote down vote up
private void showUri(Uri uri) {
    if (uri !=null) {
        Log.d("Main", "trying to load " + uri);

        //book.clearSectionOffset();
        webView.loadUrl(uri.toString());
    }
}
 
Example 37
Project: aos-Video   File: VideoInfoShowScraperFragment.java   View source code 5 votes vote down vote up
private List<EpisodeTags> getEpisodeList(ShowTags sTag) {
    ArrayList<EpisodeTags> result = new ArrayList<EpisodeTags>();
    if (sTag != null) {
        // get EpisodeTags by ShowId
        long sId = sTag.getId();
        ContentResolver cr = mContext.getContentResolver();
        Uri uri = VideoStore.Video.Media.EXTERNAL_CONTENT_URI;
        String selection = VideoStore.Video.VideoColumns.SCRAPER_SHOW_ID + "=?";
        String[] selectionArgs = new String[] {
                String.valueOf(sId)
        };
        String sortOrder = null;
        Cursor c = cr.query(uri, TagsFactory.VIDEO_COLUMNS, selection, selectionArgs, sortOrder);
        List<BaseTags> tagsList = TagsFactory.buildTagsFromVideoCursor(c);
        if (c != null)
            c.close();
        // add every EpisodeTags (should be all) to result list
        if (tagsList != null) {
            result.ensureCapacity(tagsList.size());
            for (BaseTags bTag : tagsList) {
                if (bTag instanceof EpisodeTags) {
                    EpisodeTags epTag = (EpisodeTags) bTag;
                    result.add(epTag);
                }
            }
        }
    }
    return result;
}
 
Example 38
Project: MeiLa_GNN   File: DecodeFormatManager.java   View source code 5 votes vote down vote up
static Vector<BarcodeFormat> parseDecodeFormats(Uri inputUri) {
    List<String> formats = inputUri.getQueryParameters(Intents.Scan.SCAN_FORMATS);
    if (formats != null && formats.size() == 1 && formats.get(0) != null) {
        formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0)));
    }
    return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE));
}
 
Example 39
Project: aos-MediaLib   File: HttpFile2.java   View source code 5 votes vote down vote up
/**
 * Constructor only used in a very specific case:
 * when fromUri() has not parent to list from (because Uri is the root level)
 * @param indexableUri
 */
private HttpFile2(Uri indexableUri) {
    mIsDirectory = false;
    mUri = indexableUri.toString();
    mName = indexableUri.getLastPathSegment();
    mContentPath = indexableUri.toString();
    mMimeType = null;
    mLength = -1;
    mStreamingUri= indexableUri.toString();
    mThumbnailUri = null;
}
 
Example 40
Project: AAVT   File: ExampleMp4ProcessActivity.java   View source code 5 votes vote down vote up
public void onClick(View view){
    switch (view.getId()){
        case R.id.mOpen:
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            //intent.setType(“image/*”);//选择图片
            //intent.setType(“audio/*”); //选择音频
            intent.setType("video/mp4"); //选择视频 (mp4 3gp 是android支持的视频格式)
            //intent.setType(“video/*;image/*”);//同时选择视频和图片
            //intent.setType("*/*");//无类型限制
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            startActivityForResult(intent, 1);
            break;
        case R.id.mProcess:
            mMp4Processor.startRecord();
            mMp4Processor.open();
            break;
        case R.id.mStop:
            mMp4Processor.stopRecord();
            mMp4Processor.close();
            break;
        case R.id.mPlay:
            Intent v=new Intent(Intent.ACTION_VIEW);
            v.setDataAndType(Uri.parse(tempPath),"video/mp4");
            startActivity(v);
            break;
        default:
            break;
    }
}