当前位置: 首页>>代码示例>>Java>>正文


Java Uri类代码示例

本文整理汇总了Java中android.net.Uri的典型用法代码示例。如果您正苦于以下问题:Java Uri类的具体用法?Java Uri怎么用?Java Uri使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Uri类属于android.net包,在下文中一共展示了Uri类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doInBackground

import android.net.Uri; //导入依赖的package包/类
@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);
}
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:20,代码来源:ActMFBForm.java

示例2: delete

import android.net.Uri; //导入依赖的package包/类
@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;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:19,代码来源:LauncherProvider.java

示例3: initImagePicker

import android.net.Uri; //导入依赖的package包/类
/**
 * 初始化仿微信控件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);//保存文件的高度。单位像素
}
 
开发者ID:GitLqr,项目名称:LQRWeChat,代码行数:27,代码来源:MyApp.java

示例4: enterFragment

import android.net.Uri; //导入依赖的package包/类
/**
 * 加载会话页面 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();
}
 
开发者ID:zqHero,项目名称:rongyunDemo,代码行数:22,代码来源:ConversationActivity.java

示例5: openCalendar

import android.net.Uri; //导入依赖的package包/类
@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());
  }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:23,代码来源:Calendar.java

示例6: add

import android.net.Uri; //导入依赖的package包/类
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);
}
 
开发者ID:mecid,项目名称:robird-reborn,代码行数:22,代码来源:AccountModel.java

示例7: extractBaseUri

import android.net.Uri; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:devinbrown7,项目名称:streaminglib,代码行数:27,代码来源:RtspSession.java

示例8: mapUriToFile

import android.net.Uri; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:rodrigonsh,项目名称:alerta-fraude,代码行数:30,代码来源:CordovaResourceApi.java

示例9: takePicture

import android.net.Uri; //导入依赖的package包/类
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) {
    }
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:19,代码来源:CreateACActivity.java

示例10: ShareSingleImage

import android.net.Uri; //导入依赖的package包/类
/**
 * 分享单张图片至所有第三方软件
 */
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, "分享到"));

}
 
开发者ID:tututututututu,项目名称:BaseCore,代码行数:21,代码来源:LocalShareUtils.java

示例11: onCreateLoader

import android.net.Uri; //导入依赖的package包/类
@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");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:LoginActivity.java

示例12: start

import android.net.Uri; //导入依赖的package包/类
@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;
}
 
开发者ID:rosberry,项目名称:media-picker-android,代码行数:21,代码来源:GalleryPicker.java

示例13: getRealPathFromUri

import android.net.Uri; //导入依赖的package包/类
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();
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:MediaStoreUtils.java

示例14: getType

import android.net.Uri; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:vixir,项目名称:Perfect-Day,代码行数:17,代码来源:TaskItemsContentProvider.java

示例15: getUriFromMediaStore

import android.net.Uri; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:23,代码来源:CameraLauncher.java


注:本文中的android.net.Uri类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。