當前位置: 首頁>>代碼示例>>Java>>正文


Java Uri.withAppendedPath方法代碼示例

本文整理匯總了Java中android.net.Uri.withAppendedPath方法的典型用法代碼示例。如果您正苦於以下問題:Java Uri.withAppendedPath方法的具體用法?Java Uri.withAppendedPath怎麽用?Java Uri.withAppendedPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.net.Uri的用法示例。


在下文中一共展示了Uri.withAppendedPath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getFileList

import android.net.Uri; //導入方法依賴的package包/類
public List<MetaFile2> getFileList() throws IOException, AuthenticationException {
    FTPClient ftp = Session.getInstance().getFTPClient(mUri);
    ftp.cwd(mUri.getPath()); 
    org.apache.commons.net.ftp.FTPFile[] listFiles = ftp.listFiles(); 

    if(listFiles==null)
        return null;
    ArrayList<MetaFile2> list = new ArrayList<MetaFile2>();
    for(org.apache.commons.net.ftp.FTPFile f : listFiles){
        if(!f.getName().equals("..")|| !f.getName().equals(".")){
            FTPFile2 sf = new FTPFile2(f , Uri.withAppendedPath(mUri, f.getName()));
            list.add(sf);   
        }
    }
    return list;
}
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:17,代碼來源:FTPRawLister.java

示例2: getContactsWithPush

import android.net.Uri; //導入方法依賴的package包/類
public Collection<ContactData> getContactsWithPush(Context context) {
  final ContentResolver resolver = context.getContentResolver();
  final String[] inProjection    = new String[]{PhoneLookup._ID, PhoneLookup.DISPLAY_NAME};

  List<String> pushNumbers = TextSecureDirectory.getInstance(context).getActiveNumbers();
  final Collection<ContactData> lookupData = new ArrayList<>(pushNumbers.size());

  for (String pushNumber : pushNumbers) {
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(pushNumber));
    Cursor lookupCursor = resolver.query(uri, inProjection, null, null, null);
    try {
      if (lookupCursor != null && lookupCursor.moveToFirst()) {
        final ContactData contactData = new ContactData(lookupCursor.getLong(0), lookupCursor.getString(1));
        contactData.numbers.add(new NumberData("TextSecure", pushNumber));
        lookupData.add(contactData);
      }
    } finally {
      if (lookupCursor != null)
        lookupCursor.close();
    }
  }
  return lookupData;
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:24,代碼來源:ContactAccessor.java

示例3: 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:Luodian,項目名稱:Shared-Route,代碼行數:17,代碼來源:LoginActivity.java

示例4: onCreateLoader

import android.net.Uri; //導入方法依賴的package包/類
/**
 * Loads a cursor to the list of build order names in the database for this tab's race
 * and expansion.
 */
@DebugLog
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    DbAdapter db = getDb();
    db.open();

    final String whereClause = DbAdapter.KEY_FACTION_ID + " = " + DbAdapter.getFactionID(mFaction)
            + " and " + DbAdapter.KEY_EXPANSION_ID + " = " + DbAdapter.getExpansionID(mCurrentExpansion);

    return new CursorLoader(getActivity(),
            Uri.withAppendedPath(BuildOrderProvider.BASE_URI, DbAdapter.TABLE_BUILD_ORDER),    // table URI
            new String[]{DbAdapter.KEY_BUILD_ORDER_ID, DbAdapter.KEY_NAME, DbAdapter.KEY_CREATED, DbAdapter.KEY_VS_FACTION_ID},    // columns to return
            whereClause,                                                                    // select clause
            null,                                                                            // select args
            DbAdapter.KEY_VS_FACTION_ID + ", " + DbAdapter.KEY_NAME + " asc");                // sort order
}
 
開發者ID:kiwiandroiddev,項目名稱:starcraft-2-build-player,代碼行數:21,代碼來源:RaceFragment.java

示例5: getFilePath

import android.net.Uri; //導入方法依賴的package包/類
private static Uri getFilePath(Uri xmlLocation, String videoPath) {
    if (videoPath == null)
        return null;
    Uri parentUri = Utils.getParentUrl(xmlLocation);
    if(parentUri!=null && parentUri.getPath()!=null && !parentUri.getPath().isEmpty()){
        Uri xml = Uri.withAppendedPath(parentUri, videoPath);
        return xml;
    }
    return null;
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:11,代碼來源:XmlDb.java

示例6: getContentUri

import android.net.Uri; //導入方法依賴的package包/類
/**
* Gets the content:// URI from the given corresponding path to a file
*
* @param context
*            場景
* @param file
*            文件
* @return content Uri
*/
  public static Uri getContentUri(Context context, File file) {
      String filePath = file.getAbsolutePath();
      Cursor cursor = context.getContentResolver().query(
              MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
              new String[] { MediaStore.Images.Media._ID },
              MediaStore.Images.Media.DATA + "=? ",
              new String[] { filePath }, null);
      if (cursor != null && cursor.moveToFirst()) {
          int id = cursor.getInt(cursor
                  .getColumnIndex(MediaStore.MediaColumns._ID));
          Uri baseUri = Uri.parse("content://media/external/images/media");
          if (!cursor.isClosed()) {
              cursor.close();
          }
          return Uri.withAppendedPath(baseUri, "" + id);
      } else {
          if (file.exists()) {
              ContentValues values = new ContentValues();
              values.put(MediaStore.Images.Media.DATA, filePath);
              return context.getContentResolver().insert(
                      MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
          } else {
              return null;
          }
      }
  }
 
開發者ID:YMlion,項目名稱:leisure-glance,代碼行數:36,代碼來源:UriUtil.java

示例7: insert

import android.net.Uri; //導入方法依賴的package包/類
@Override
public Uri insert(Uri uri, ContentValues values) {
    if (isEstadosUri(uri)) {
        long id = db.getWritableDatabase().insert(SQLEstadosHelper.DATABASE_TABLE,null,values);
        return Uri.withAppendedPath(ContentProviderContract.CONTENT_ESTADOS_URI, Long.toString(id));
    }
    else return null;
}
 
開發者ID:if710,項目名稱:2017.2-codigo,代碼行數:9,代碼來源:SQLiteContentProvider.java

示例8: getView

import android.net.Uri; //導入方法依賴的package包/類
public static SynchronizedView getView(Context ctx, String name, Record record) {
	String appendedPath = "records/" + record.getId() + "/views/" + name;
	Uri contentUri = Uri.withAppendedPath(HVContentContract.CONTENT_URI, appendedPath);

	Cursor cursor = ctx.getContentResolver().query(
			contentUri,
		    new String[] { "query", "date_synced" },
		    null, null, null);

	SynchronizedView view = null;
	
	try {
           if (cursor.getCount() > 0) {
               cursor.moveToFirst();

               String serializedQuery = cursor.getString(0);
               long syncDateMillis = cursor.getLong(1);
              
               view = new SynchronizedView(
                   ctx,
                   record,
                   name,
                   XmlSerializer.read(ThingRequestGroup2.class, serializedQuery),
                   new Date(syncDateMillis));
           }
	} catch (Exception e) {
		throw new HVException("Could not get View.", e);
	}
	
	return view;
}
 
開發者ID:Microsoft,項目名稱:healthvault-java-sdk,代碼行數:32,代碼來源:SynchronizedView.java

示例9: getRecordContactName

import android.net.Uri; //導入方法依賴的package包/類
public String getRecordContactName(Context context, String number)
  {
try
{
   	String contactName = "";
   	
   	Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
       Cursor cursor = contentResolver.query(uri, new String[]{PhoneLookup._ID,PhoneLookup.DISPLAY_NAME}, null, null, null);
	
       if(cursor.moveToFirst())
       {
           contactName = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME));
       }
       
       if(cursor != null && !cursor.isClosed())
       {
           cursor.close();
       }
       
       return contactName;
}
catch (Exception e)
{
	Log.w("DatabaseManager", "getRecordContactName : " + context.getString(R.string.log_database_manager_error_request) + " : " + e);
	
	return null;
}
  }
 
開發者ID:vassela,項目名稱:AC2RD,代碼行數:29,代碼來源:DatabaseManager.java

示例10: setUp

import android.net.Uri; //導入方法依賴的package包/類
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);

  uri = Uri.withAppendedPath(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, "123");
  fetcher = new ThumbFetcher(uri, opener);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:8,代碼來源:ThumbFetcherTest.java

示例11: downloadVideo

import android.net.Uri; //導入方法依賴的package包/類
private void downloadVideo(String pathvideo) {
    /*if (!(pathvideo.contains("fbcdn")))
    {
        Toast.makeText(getContext(), "Please Enter Only Video Url", Toast.LENGTH_LONG).show();
    }*/
    if(pathvideo.contains("story"))
    {
        homeFragment.getUrlfromUrlDownload(pathvideo);
    }
    else
    {
            File directory = new File(Environment.getExternalStorageDirectory() + File.separator + "FacebookVideos");
            directory.mkdirs();
            DownloadManager.Request request = new DownloadManager.Request(Uri.parse(pathvideo));
            request.allowScanningByMediaScanner();
            request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
            File root = new File(Environment.getExternalStorageDirectory() + File.separator + "Facebook Videos");
            int Number = pref.getFileName();
            Uri path = Uri.withAppendedPath(Uri.fromFile(root), "Video-" + Number + ".mp4");
            request.setDestinationUri(path);
            DownloadManager dm = (DownloadManager) getActivity().getSystemService(getActivity().DOWNLOAD_SERVICE);
            ArrayList<String> urldownloadFragmentList = (new HomeFragment()).getList();
            if(urldownloadFragmentList.contains(pathvideo))
            {
                Toast.makeText(getActivity().getApplicationContext(),"The Video is Already Downloading",Toast.LENGTH_LONG).show();
            }
            else
            {
                urldownloadFragmentList.add(pathvideo);
                dm.enqueue(request);
                Toast.makeText(getActivity().getApplicationContext(),"Downloading Video-"+Number+".mp4",Toast.LENGTH_LONG).show();
                Number++;
                pref.setFileName(Number);
            }
    }
}
 
開發者ID:adarshgumashta,項目名稱:Facebook-Video-Downloader,代碼行數:38,代碼來源:UrlDownloadFragment.java

示例12: getContactsDetails

import android.net.Uri; //導入方法依賴的package包/類
protected Participant getContactsDetails(String address) throws IOException {
    Uri contactUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(address));

    Cursor phones = deskDroidService.getApplicationContext().getContentResolver().query(contactUri,
            new String[]{
                    ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
                    "number",
                    ContactsContract.CommonDataKinds.Phone.PHOTO_THUMBNAIL_URI},
            null, null, null);
    Participant participant = new Participant();
    if (phones.moveToNext()) {
        participant.setName(phones.getString(phones.getColumnIndex(
                ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)));
        participant.setPhoneNumber(phones.getString(phones.getColumnIndex("number")));

        String image_uri = phones.getString(phones.getColumnIndex(
                ContactsContract.CommonDataKinds.Phone.PHOTO_THUMBNAIL_URI));
        if (image_uri != null) {
            try (InputStream input = deskDroidService.getApplicationContext().
                    getContentResolver().openInputStream(Uri.parse(image_uri));
                 ByteArrayOutputStream buffer = new ByteArrayOutputStream()) {
                int nRead;
                byte[] data = new byte[16384];

                while ((nRead = input.read(data, 0, data.length)) != -1) {
                    buffer.write(data, 0, nRead);
                }

                buffer.flush();
                participant.setThumbnail(Base64.encodeToString(buffer.toByteArray(), Base64.DEFAULT));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    phones.close();
    return participant;
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:39,代碼來源:DeskDroidResource.java

示例13: onCreateLoader

import android.net.Uri; //導入方法依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String accountUuid = accountUuids[id];
    Account account = preferences.getAccount(accountUuid);

    String threadId = getThreadId(search);

    Uri uri;
    String[] projection;
    boolean needConditions;
    if (threadId != null) {
        uri = Uri.withAppendedPath(EmailProvider.CONTENT_URI, "account/" + accountUuid + "/thread/" + threadId);
        projection = PROJECTION;
        needConditions = false;
    } else if (showingThreadedList) {
        uri = Uri.withAppendedPath(EmailProvider.CONTENT_URI, "account/" + accountUuid + "/messages/threaded");
        projection = THREADED_PROJECTION;
        needConditions = true;
    } else {
        uri = Uri.withAppendedPath(EmailProvider.CONTENT_URI, "account/" + accountUuid + "/messages");
        projection = PROJECTION;
        needConditions = true;
    }

    StringBuilder query = new StringBuilder();
    List<String> queryArgs = new ArrayList<>();
    if (needConditions) {
        boolean selectActive = activeMessage != null && activeMessage.getAccountUuid().equals(accountUuid);

        if (selectActive) {
            query.append("(" + MessageColumns.UID + " = ? AND " + SpecialColumns.FOLDER_REMOTE_ID + " = ?) OR (");
            queryArgs.add(activeMessage.getUid());
            queryArgs.add(activeMessage.getFolderId());
        }

        SqlQueryBuilder.buildWhereClause(account, search.getConditions(), query, queryArgs);

        if (selectActive) {
            query.append(')');
        }
    }

    String selection = query.toString();
    String[] selectionArgs = queryArgs.toArray(new String[0]);

    String sortOrder = buildSortOrder();

    return new CursorLoader(getActivity(), uri, projection, selection, selectionArgs,
            sortOrder);
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:51,代碼來源:MessageListFragment.java

示例14: books

import android.net.Uri; //導入方法依賴的package包/類
public static Uri books() {
    return Uri.withAppendedPath(AUTHORITY_URI, MatcherUri.BOOKS);
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:4,代碼來源:ProviderContract.java

示例15: notifyChange

import android.net.Uri; //導入方法依賴的package包/類
void notifyChange() {
    Uri uri = Uri.withAppendedPath(EmailProvider.CONTENT_URI, "account/" + account.getUuid() + "/messages");
    contentResolver.notifyChange(uri, null);
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:5,代碼來源:LocalStore.java


注:本文中的android.net.Uri.withAppendedPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。