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


Java MimeTypeMap.getExtensionFromMimeType方法代码示例

本文整理汇总了Java中android.webkit.MimeTypeMap.getExtensionFromMimeType方法的典型用法代码示例。如果您正苦于以下问题:Java MimeTypeMap.getExtensionFromMimeType方法的具体用法?Java MimeTypeMap.getExtensionFromMimeType怎么用?Java MimeTypeMap.getExtensionFromMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.webkit.MimeTypeMap的用法示例。


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

示例1: resultReturned

import android.webkit.MimeTypeMap; //导入方法依赖的package包/类
/**
 * Callback method to get the result returned by the image picker activity
 *
 * @param requestCode a code identifying the request.
 * @param resultCode a code specifying success or failure of the activity
 * @param data the returned data, in this case an Intent whose data field
 *        contains the image's content URI.
 */
public void resultReturned(int requestCode, int resultCode, Intent data) {
  if (requestCode == this.requestCode && resultCode == Activity.RESULT_OK) {
    Uri selectedImage = data.getData();
    selectionURI = selectedImage.toString();
    Log.i(LOG_TAG, "selectionURI = " + selectionURI);

    // get the file type extension from the intent data Uri
    ContentResolver cR = container.$context().getContentResolver();
    MimeTypeMap mime = MimeTypeMap.getSingleton();
    String extension = "." + mime.getExtensionFromMimeType(cR.getType(selectedImage));
    Log.i(LOG_TAG, "extension = " + extension);

    // save the image to a temp file in external storage, using a name
    // that includes the extension
    saveSelectedImageToExternalStorage(extension);
    AfterPicking();
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:27,代码来源:ImagePicker.java

示例2: getMimeType

import android.webkit.MimeTypeMap; //导入方法依赖的package包/类
private static String getMimeType(Context context, Uri uri) {
  String extension;

  //Check uri format to avoid null
  if (uri.getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
    //If scheme is a content
    final MimeTypeMap mime = MimeTypeMap.getSingleton();
    extension = mime.getExtensionFromMimeType(context.getContentResolver().getType(uri));
  } else {
    //If scheme is a File
    //This will replace white spaces with %20 and also other special characters. This will avoid returning null values on file name with spaces and special characters.
    extension = MimeTypeMap
        .getFileExtensionFromUrl(Uri.fromFile(new File(uri.getPath())).toString());

  }

  return extension;
}
 
开发者ID:azmedien,项目名称:kolibri-android,代码行数:19,代码来源:CardboardActivity.java

示例3: generateOutputFileName

import android.webkit.MimeTypeMap; //导入方法依赖的package包/类
private String generateOutputFileName(@NonNull String contentType, long timestamp) {
  MimeTypeMap      mimeTypeMap   = MimeTypeMap.getSingleton();
  String           extension     = mimeTypeMap.getExtensionFromMimeType(contentType);
  SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd-HHmmss");
  String           base          = "signal-" + dateFormatter.format(timestamp);

  if (extension == null) extension = "attach";

  return base + "." + extension;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:11,代码来源:SaveAttachmentTask.java

示例4: onCreate

import android.webkit.MimeTypeMap; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.transparent_activity);

    String action = getIntent().getAction();
    String type = getIntent().getType();

    if (Intent.ACTION_SEND.equals(action)) {
        getPermission();
        uri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM);

        Log.d("delf", "[DEBUG] shared date type is " + type);
        ContentResolver cR = getContentResolver();
        MimeTypeMap mime = MimeTypeMap.getSingleton();
        String mimeType = mime.getExtensionFromMimeType(cR.getType(uri)); // get "file name extension"
        Log.d("delf", "[DEBUG] shared date mime type is " + mimeType);

        showUploadProgressNoti();

        if (type.startsWith("image/")) {
            Toast.makeText(getApplicationContext(), R.string.shareImage, Toast.LENGTH_SHORT).show();

            bitmap = getBitmapByUri(uri);
            new EndpointInBackGround()
                    .setSendBitmapImage(bitmap)
                    .execute(Message.UPLOAD, "image");
        } else {
            Toast.makeText(getApplicationContext(), R.string.shareFile, Toast.LENGTH_SHORT).show();
            Log.d("delf", "[DEBUG] uri.getPath() = " + uri.getPath());

            String filePath = getPathFromUri(uri);
            Log.d("hee", "[DEBUG] filePath = " + filePath);

            new EndpointInBackGround()
                    .setFilePath(filePath)
                    .execute(Message.UPLOAD, "file");
        }

    }

    finish();
}
 
开发者ID:Team-Sprout,项目名称:Clipcon-AndroidClient,代码行数:44,代码来源:TransparentActivity.java

示例5: getFileExtension

import android.webkit.MimeTypeMap; //导入方法依赖的package包/类
private String getFileExtension(Uri uri){
    ContentResolver contentResolver = getContentResolver();
    MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();

    return mimeTypeMap.getExtensionFromMimeType(contentResolver.getType(uri));
}
 
开发者ID:marckregio,项目名称:maklib,代码行数:7,代码来源:FirebaseStorageActivity.java

示例6: getFileExt

import android.webkit.MimeTypeMap; //导入方法依赖的package包/类
public String getFileExt(Uri uri1){
    ContentResolver contentResolver = getContentResolver();
    MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
    return mimeTypeMap.getExtensionFromMimeType(contentResolver.getType(uri1));
}
 
开发者ID:nSpider,项目名称:Paathshala,代码行数:6,代码来源:upl.java


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