本文整理匯總了Java中android.net.Uri.decode方法的典型用法代碼示例。如果您正苦於以下問題:Java Uri.decode方法的具體用法?Java Uri.decode怎麽用?Java Uri.decode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.net.Uri
的用法示例。
在下文中一共展示了Uri.decode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getFileForUri
import android.net.Uri; //導入方法依賴的package包/類
public File getFileForUri(Uri uri) {
String path = uri.getEncodedPath();
int splitIndex = path.indexOf(47, 1);
String tag = Uri.decode(path.substring(1, splitIndex));
path = Uri.decode(path.substring(splitIndex + 1));
File root = (File) this.mRoots.get(tag);
if (root == null) {
throw new IllegalArgumentException("Unable to find configured root for " + uri);
}
File file = new File(root, path);
try {
file = file.getCanonicalFile();
if (file.getPath().startsWith(root.getPath())) {
return file;
}
throw new SecurityException("Resolved path jumped beyond configured root");
} catch (IOException e) {
throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
}
}
示例2: getFileForUri
import android.net.Uri; //導入方法依賴的package包/類
@Override
public File getFileForUri(Uri uri) {
String path = uri.getEncodedPath();
final int splitIndex = path.indexOf('/', 1);
final String tag = Uri.decode(path.substring(1, splitIndex));
path = Uri.decode(path.substring(splitIndex + 1));
final File root = mRoots.get(tag);
if (root == null) {
throw new IllegalArgumentException("Unable to find configured root for " + uri);
}
File file = new File(root, path);
try {
file = file.getCanonicalFile();
} catch (IOException e) {
throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
}
if (!file.getPath().startsWith(root.getPath())) {
throw new SecurityException("Resolved path jumped beyond configured root");
}
return file;
}
示例3: parse
import android.net.Uri; //導入方法依賴的package包/類
public static MailTo parse(Uri uri) throws NullPointerException, IllegalArgumentException {
if (uri == null || uri.toString() == null) {
throw new NullPointerException("Argument 'uri' must not be null");
}
if (!isMailTo(uri)) {
throw new IllegalArgumentException("Not a mailto scheme");
}
String schemaSpecific = uri.getSchemeSpecificPart();
int end = schemaSpecific.indexOf('?');
if (end == -1) {
end = schemaSpecific.length();
}
CaseInsensitiveParamWrapper params =
new CaseInsensitiveParamWrapper(Uri.parse("foo://bar?" + uri.getEncodedQuery()));
// Extract the recipient's email address from the mailto URI if there's one.
String recipient = Uri.decode(schemaSpecific.substring(0, end));
List<String> toList = params.getQueryParameters(TO);
if (recipient.length() != 0) {
toList.add(0, recipient);
}
List<String> ccList = params.getQueryParameters(CC);
List<String> bccList = params.getQueryParameters(BCC);
Address[] toAddresses = toAddressArray(toList);
Address[] ccAddresses = toAddressArray(ccList);
Address[] bccAddresses = toAddressArray(bccList);
String subject = getFirstParameterValue(params, SUBJECT);
String body = getFirstParameterValue(params, BODY);
return new MailTo(toAddresses, ccAddresses, bccAddresses, subject, body);
}
示例4: initToolBar
import android.net.Uri; //導入方法依賴的package包/類
@Override
public void initToolBar() {
String filePath = Uri.decode(getIntent().getDataString().replace("file://", ""));
String fileName = filePath.substring(filePath.lastIndexOf("/") + 1, filePath.lastIndexOf("."));
mCommonToolbar.setTitle(fileName);
mCommonToolbar.setNavigationIcon(R.drawable.ab_back);
}
示例5: buildSearchUrl
import android.net.Uri; //導入方法依賴的package包/類
public String buildSearchUrl(final String searchTerm) {
if (resultsUris.isEmpty()) {
return searchTerm;
}
// The parse should have put the best URL for this device at the beginning of the list.
final Uri searchUri = resultsUris.get(0);
final String template = Uri.decode(searchUri.toString());
final String urlWithSubstitutions = paramSubstitution(template, Uri.encode(searchTerm));
return UrlUtils.normalize(urlWithSubstitutions); // User-entered search engines may need normalization.
}
示例6: getPath
import android.net.Uri; //導入方法依賴的package包/類
/**
* Get the path for the file:/// only
*
* @param uri
* @return
*/
public static String getPath(String uri) {
Log.i("FileUtils#getPath(%s)", uri);
if (TextUtils.isEmpty(uri))
return null;
if (uri.startsWith("file://") && uri.length() > 7)
return Uri.decode(uri.substring(7));
return Uri.decode(uri);
}
示例7: parseSipContact
import android.net.Uri; //導入方法依賴的package包/類
/**
* Parse a sip contact
*
* @param sipUri string sip contact
* @return a ParsedSipContactInfos which contains uri parts. If not match
* return the object with blank fields
*/
public static ParsedSipContactInfos parseSipContact(String sipUri) {
ParsedSipContactInfos parsedInfos = new ParsedSipContactInfos();
if (!TextUtils.isEmpty(sipUri)) {
Matcher m = SIP_CONTACT_PATTERN.matcher(sipUri);
if (m.matches()) {
parsedInfos.displayName = Uri.decode(m.group(1).trim());
parsedInfos.domain = m.group(4);
parsedInfos.userName = Uri.decode(m.group(3));
parsedInfos.scheme = m.group(2);
}else {
// Try to consider that as host
m = SIP_HOST_PATTERN.matcher(sipUri);
if(m.matches()) {
parsedInfos.displayName = Uri.decode(m.group(1).trim());
parsedInfos.domain = m.group(3);
parsedInfos.scheme = m.group(2);
}else {
m = SIP_CONTACT_ADDRESS_PATTERN.matcher(sipUri);
if(m.matches()) {
parsedInfos.userName = Uri.decode(m.group(1));
parsedInfos.domain = m.group(2);
}else {
// Final fallback, we have only a username given
parsedInfos.userName = sipUri;
}
}
}
}
return parsedInfos;
}
示例8: onCreate
import android.net.Uri; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// get the file path
Uri uri = getIntent().getData();
final String path = Uri.decode(uri.getEncodedPath());
// set up UI
setContentView(R.layout.activity_doc_view);
mDocActivityView = (DocActivityView) findViewById(R.id.doc_view);
mDocActivityView.showUI(true); // set to false for no built-in UI
// set a listener for when it's done
mDocActivityView.setOnDoneListener(new DocActivityView.OnDoneListener()
{
@Override
public void done()
{
finish();
}
});
// Go!
mDocActivityView.start(path);
}
示例9: getPath
import android.net.Uri; //導入方法依賴的package包/類
public static String getPath(Context context, String url) {
if (isContentUri(url)) {
url = Uri.decode(url);
String myUrl = getPath(context, Uri.parse(url));
return myUrl;
}
return url;
}
示例10: accept
import android.net.Uri; //導入方法依賴的package包/類
@Override
public boolean accept(File pathname) {
if (pathname.isFile()) {
String decodeName = Uri.decode(pathname.getName());
if (decodeName.startsWith("trainDetail_")) {
return true;
} else {
return false;
}
}
{
return false;
}
}
示例11: initToolBar
import android.net.Uri; //導入方法依賴的package包/類
@Override
public void initToolBar() {
chmFilePath = Uri.decode(getIntent().getDataString().replace("file://", ""));
chmFileName = chmFilePath.substring(chmFilePath.lastIndexOf("/") + 1, chmFilePath.lastIndexOf("."));
mCommonToolbar.setTitle(chmFileName);
mCommonToolbar.setNavigationIcon(R.drawable.ab_back);
}
示例12: query
import android.net.Uri; //導入方法依賴的package包/類
private void query(){
if(next_href!=null){
int index=next_href.indexOf("&q=")+3;
if(next_href.length()>index){
int lastIndex=next_href.indexOf("&",index);
query=next_href.substring(index,lastIndex!=-1?lastIndex:next_href.length());
query=Uri.decode(query);
}
}
}
示例13: initDatas
import android.net.Uri; //導入方法依賴的package包/類
@Override
public void initDatas() {
recommendBooks = (Recommend.RecommendBooks) getIntent().getSerializableExtra(INTENT_BEAN);
bookId = recommendBooks._id;
isFromSD = getIntent().getBooleanExtra(INTENT_SD, false);
if (Intent.ACTION_VIEW.equals(getIntent().getAction())) {
String filePath = Uri.decode(getIntent().getDataString().replace("file://", ""));
String fileName;
if (filePath.lastIndexOf(".") > filePath.lastIndexOf("/")) {
fileName = filePath.substring(filePath.lastIndexOf("/") + 1, filePath.lastIndexOf("."));
} else {
fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
}
CollectionsManager.getInstance().remove(fileName);
// 轉存
File desc = FileUtils.createWifiTranfesFile(fileName);
FileUtils.fileChannelCopy(new File(filePath), desc);
// 建立
recommendBooks = new Recommend.RecommendBooks();
recommendBooks.isFromSD = true;
recommendBooks._id = fileName;
recommendBooks.title = fileName;
isFromSD = true;
}
EventBus.getDefault().register(this);
showDialog();
mTvBookReadTocTitle.setText(recommendBooks.title);
intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
intentFilter.addAction(Intent.ACTION_TIME_TICK);
CollectionsManager.getInstance().setRecentReadingTime(bookId);
Observable.timer(1000, TimeUnit.MILLISECONDS)
.subscribe(new Action1<Long>() {
@Override
public void call(Long aLong) {
//延遲1秒刷新書架
EventManager.refreshCollectionList();
}
});
}
示例14: initDatas
import android.net.Uri; //導入方法依賴的package包/類
@Override
public void initDatas() {
recommendBooks = (Recommend.RecommendBooks) getIntent().getSerializableExtra(INTENT_BEAN);
bookId = recommendBooks._id;
isFromSD = getIntent().getBooleanExtra(INTENT_SD, false);
if (Intent.ACTION_VIEW.equals(getIntent().getAction())) {
String filePath = Uri.decode(getIntent().getDataString().replace("file://", ""));
String fileName;
if (filePath.lastIndexOf(".") > filePath.lastIndexOf("/")) {
fileName = filePath.substring(filePath.lastIndexOf("/") + 1, filePath.lastIndexOf("."));
} else {
fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
}
CollectionsManager.getInstance().remove(fileName);
// 轉存
File desc = FileUtils.createWifiTranfesFile(fileName);
FileUtils.fileChannelCopy(new File(filePath), desc);
// 建立
recommendBooks = new Recommend.RecommendBooks();
recommendBooks.isFromSD = true;
recommendBooks._id = fileName;
recommendBooks.title = fileName;
isFromSD = true;
}
EventBus.getDefault().register(this);
showDialog();
mTvBookReadTocTitle.setText(recommendBooks.title);
mTtsPlayer = TTSPlayerUtils.getTTSPlayer();
ttsConfig = TTSPlayerUtils.getTtsConfig();
intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
intentFilter.addAction(Intent.ACTION_TIME_TICK);
CollectionsManager.getInstance().setRecentReadingTime(bookId);
Observable.timer(1000, TimeUnit.MILLISECONDS)
.subscribe(new Action1<Long>() {
@Override
public void call(Long aLong) {
//延遲1秒刷新書架
EventManager.refreshCollectionList();
}
});
}
示例15: getAu
import android.net.Uri; //導入方法依賴的package包/類
public String getAu() {
return Uri.decode(this.au);
}