本文整理汇总了Java中android.net.Uri.Builder类的典型用法代码示例。如果您正苦于以下问题:Java Builder类的具体用法?Java Builder怎么用?Java Builder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Builder类属于android.net.Uri包,在下文中一共展示了Builder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildUrl
import android.net.Uri.Builder; //导入依赖的package包/类
public String buildUrl(String picid) {
Builder builder = Uri.parse(SHARE_URL).buildUpon();
builder.appendQueryParameter("title", this.mShareContent);
builder.appendQueryParameter("version", "0031105000");
if (!TextUtils.isEmpty(this.mAppKey)) {
builder.appendQueryParameter("source", this.mAppKey);
}
if (!TextUtils.isEmpty(this.mToken)) {
builder.appendQueryParameter("access_token", this.mToken);
}
String aid = Utility.getAid(this.mContext, this.mAppKey);
if (!TextUtils.isEmpty(aid)) {
builder.appendQueryParameter("aid", aid);
}
if (!TextUtils.isEmpty(this.mAppPackage)) {
builder.appendQueryParameter(REQ_PARAM_PACKAGENAME, this.mAppPackage);
}
if (!TextUtils.isEmpty(this.mHashKey)) {
builder.appendQueryParameter(REQ_PARAM_KEY_HASH, this.mHashKey);
}
if (!TextUtils.isEmpty(picid)) {
builder.appendQueryParameter(REQ_PARAM_PICINFO, picid);
}
return builder.build().toString();
}
示例2: isSipPhone
import android.net.Uri.Builder; //导入依赖的package包/类
/**
* Returns true if this device can be used to make sip calls
*/
/*
public static boolean isSipPhone(Context context) {
if (!sIsInitialized) initialize(context);
return sIsSipPhone;
}
*/
public static Intent getPriviledgedIntent(String number) {
Intent i = new Intent("android.intent.action.CALL_PRIVILEGED");
Builder b = new Builder();
b.scheme("tel").appendPath(number);
i.setData(b.build());
return i;
}
示例3: confirmDeleteThread
import android.net.Uri.Builder; //导入依赖的package包/类
private void confirmDeleteThread(final String from) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.confirm_dialog_title)
.setIcon(android.R.drawable.ic_dialog_alert)
.setCancelable(true)
.setPositiveButton(R.string.delete, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(TextUtils.isEmpty(from)) {
getActivity().getContentResolver().delete(SipMessage.MESSAGE_URI, null, null);
}else {
Builder threadUriBuilder = SipMessage.THREAD_ID_URI_BASE.buildUpon();
threadUriBuilder.appendEncodedPath(from);
getActivity().getContentResolver().delete(threadUriBuilder.build(), null, null);
}
}
})
.setNegativeButton(R.string.no, null)
.setMessage(TextUtils.isEmpty(from)
? R.string.confirm_delete_all_conversations
: R.string.confirm_delete_conversation)
.show();
}
示例4: buildNewUri
import android.net.Uri.Builder; //导入依赖的package包/类
private Uri buildNewUri(Uri uri, String targetAuthority) {
Builder b = new Builder();
b.scheme(uri.getScheme());
b.authority(targetAuthority);
b.path(uri.getPath());
if (VERSION.SDK_INT >= 11) {
Set<String> names = uri.getQueryParameterNames();
if (names != null && names.size() > 0) {
for (String name : names) {
if (!TextUtils.equals(name, ApkConstant.EXTRA_TARGET_AUTHORITY)) {
b.appendQueryParameter(name, uri.getQueryParameter(name));
}
}
}
} else {
b.query(uri.getQuery());
}
b.fragment(uri.getFragment());
return b.build();
}
示例5: getIntent
import android.net.Uri.Builder; //导入依赖的package包/类
public static Intent getIntent(Context context, String titleResId, String url, String appId) {
if (ValidUtils.isUrlValid(url)) {
try {
Intent i = new Intent(context, AssistActivity.class);
i.addFlags(268435456);
KVUtils.put(i, KEY_TITLE_RESID, titleResId);
Builder ub = Uri.parse(url).buildUpon();
ub.appendQueryParameter("pv", "1");
ub.appendQueryParameter("titlebar", "0");
ub.appendQueryParameter("appid", appId);
ub.appendQueryParameter(a.c, "http://auther.coolyun.com");
ub.appendQueryParameter("clientype", SystemUtils.getDeviceType());
ub.appendQueryParameter(HOME_RECOMMEND_PARAMETERS.DEVICEID_KEY, SystemUtils.getDeviceId(context));
ub.appendQueryParameter("devmodel", SystemUtils.getDeviceModel());
ub.appendQueryParameter("netype", SystemUtils.getNetworkType(context));
ub.appendQueryParameter("tm", TimeUtils.nowTime());
KVUtils.put(i, "url", ub.toString());
return i;
} catch (Throwable t) {
LOG.e(TAG, "[url:" + url + "][appId:" + appId + "] create intent failed(Throwable)", t);
return null;
}
}
LOG.e(TAG, "[url:" + url + "][appId:" + appId + "] url invalid");
return null;
}
示例6: addCommonParam
import android.net.Uri.Builder; //导入依赖的package包/类
protected Builder addCommonParam(Builder ub) {
append(ub, CLIENT_TYPE, this.clientType);
append(ub, "devid", getDeviceId());
append(ub, MAC_ID, getMacId());
append(ub, SN_ID, getSnId());
append(ub, PKG_NAME, getpkgName());
append(ub, JAR_VERSION, "2.2.1");
append(ub, UACBRAND, Config.getUacBrand());
append(ub, PKG_VERSION, getAppVersion());
append(ub, MEID_ID, getMeidId());
append(ub, DEVICE_MODEL, getDeviceModel());
append(ub, NETWORK_TYPE, SystemUtils.getNetworkType(ContextUtils.getContext()));
append(ub, IS_GZIP, this.gzip);
append(ub, PROTOCOL_VERSION, this.protocolVersion);
append(ub, REQUEST_TIME, TimeUtils.nowTime());
return ub;
}
示例7: getUriForFile
import android.net.Uri.Builder; //导入依赖的package包/类
public Uri getUriForFile(File file) {
try {
String rootPath;
String path = file.getCanonicalPath();
Entry<String, File> mostSpecific = null;
for (Entry<String, File> root : this.mRoots.entrySet()) {
rootPath = ((File) root.getValue()).getPath();
if (path.startsWith(rootPath) && (mostSpecific == null || rootPath.length() > ((File) mostSpecific.getValue()).getPath().length())) {
mostSpecific = root;
}
}
if (mostSpecific == null) {
throw new IllegalArgumentException("Failed to find configured root that contains " + path);
}
rootPath = ((File) mostSpecific.getValue()).getPath();
if (rootPath.endsWith("/")) {
path = path.substring(rootPath.length());
} else {
path = path.substring(rootPath.length() + 1);
}
return new Builder().scheme(WidgetRequestParam.REQ_PARAM_COMMENT_CONTENT).authority(this.mAuthority).encodedPath(Uri.encode((String) mostSpecific.getKey()) + LetvUtils.CHARACTER_BACKSLASH + Uri.encode(path, "/")).build();
} catch (IOException e) {
throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
}
}
示例8: buildNewUri
import android.net.Uri.Builder; //导入依赖的package包/类
private Uri buildNewUri(Uri uri, String targetAuthority) {
Uri.Builder b = new Builder();
b.scheme(uri.getScheme());
b.authority(targetAuthority);
b.path(uri.getPath());
if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
Set<String> names = uri.getQueryParameterNames();
if (names != null && names.size() > 0) {
for (String name : names) {
if (!TextUtils.equals(name, Env.EXTRA_TARGET_AUTHORITY)) {
b.appendQueryParameter(name, uri.getQueryParameter(name));
}
}
}
} else {
b.query(uri.getQuery());
}
b.fragment(uri.getFragment());
return b.build();
}
示例9: getSearchManagerSuggestions
import android.net.Uri.Builder; //导入依赖的package包/类
Cursor getSearchManagerSuggestions(SearchableInfo searchable, String query, int limit) {
if (searchable == null) {
return null;
}
String authority = searchable.getSuggestAuthority();
if (authority == null) {
return null;
}
Builder uriBuilder = new Builder().scheme(Utils.RESPONSE_CONTENT).authority(authority).query("").fragment("");
String contentPath = searchable.getSuggestPath();
if (contentPath != null) {
uriBuilder.appendEncodedPath(contentPath);
}
uriBuilder.appendPath("search_suggest_query");
String selection = searchable.getSuggestSelection();
String[] selArgs = null;
if (selection != null) {
selArgs = new String[]{query};
} else {
uriBuilder.appendPath(query);
}
if (limit > 0) {
uriBuilder.appendQueryParameter("limit", String.valueOf(limit));
}
return this.mContext.getContentResolver().query(uriBuilder.build(), null, selection, selArgs, null);
}
示例10: getUriForFile
import android.net.Uri.Builder; //导入依赖的package包/类
public Uri getUriForFile(File file) {
try {
String rootPath;
String path = file.getCanonicalPath();
Entry<String, File> mostSpecific = null;
for (Entry<String, File> root : this.mRoots.entrySet()) {
rootPath = ((File) root.getValue()).getPath();
if (path.startsWith(rootPath) && (mostSpecific == null || rootPath.length() > ((File) mostSpecific.getValue()).getPath().length())) {
mostSpecific = root;
}
}
if (mostSpecific == null) {
throw new IllegalArgumentException("Failed to find configured root that contains " + path);
}
rootPath = ((File) mostSpecific.getValue()).getPath();
if (rootPath.endsWith("/")) {
path = path.substring(rootPath.length());
} else {
path = path.substring(rootPath.length() + 1);
}
return new Builder().scheme(Utils.RESPONSE_CONTENT).authority(this.mAuthority).encodedPath(Uri.encode((String) mostSpecific.getKey()) + '/' + Uri.encode(path, "/")).build();
} catch (IOException e) {
throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
}
}
示例11: buildUrl
import android.net.Uri.Builder; //导入依赖的package包/类
public static URL buildUrl() {
Uri baseUri = Uri.parse(BASE_URL);
Builder uriBuilder = baseUri.buildUpon();
Map<String, String> paramMap = getParamMap();
if (paramMap != null) {
for (String param : paramMap.keySet()) {
String value = paramMap.get(param);
uriBuilder.appendQueryParameter(param, value);
}
}
String uriString = uriBuilder.toString();
URL url = null;
try {
url = new URL(uriString);
} catch (MalformedURLException e) {
Timber.e(e, "Problem building the URL");
}
return url;
}
示例12: getReviewsUrl
import android.net.Uri.Builder; //导入依赖的package包/类
private static String getReviewsUrl(String paramString, boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3)
{
Uri.Builder localBuilder = Uri.parse(paramString).buildUpon();
if (paramBoolean) {
localBuilder.appendQueryParameter("dfil", "1");
}
if (paramInt1 > 0) {
localBuilder.appendQueryParameter("vc", Integer.toString(paramInt1));
}
if (paramInt2 > 0) {
localBuilder.appendQueryParameter("rating", Integer.toString(paramInt2));
}
if (paramInt3 >= 0) {
localBuilder.appendQueryParameter("sort", Integer.toString(paramInt3));
}
return localBuilder.toString();
}
示例13: getBackendCanonicalIconUri
import android.net.Uri.Builder; //导入依赖的package包/类
private Uri getBackendCanonicalIconUri(int paramInt)
{
if (paramInt != 3) {
try
{
String str = IntentUtils.getPackageName(paramInt);
PackageManager localPackageManager = this.mContext.getPackageManager();
int i = ((ResolveInfo)localPackageManager.queryIntentActivities(localPackageManager.getLaunchIntentForPackage(str), 65536).get(0)).activityInfo.applicationInfo.icon;
if (i != 0)
{
Uri localUri = new Uri.Builder().scheme("android.resource").authority(str).path(Integer.toString(i)).build();
return localUri;
}
}
catch (Exception localException)
{
return null;
}
}
return null;
}
示例14: getDismissPendingIntent
import android.net.Uri.Builder; //导入依赖的package包/类
public static PendingIntent getDismissPendingIntent(Context paramContext, int paramInt1, Document paramDocument, int paramInt2, int paramInt3)
{
if (!paramDocument.hasNeutralDismissal()) {
return null;
}
String str = paramDocument.getNeutralDismissal().url;
Uri.Builder localBuilder = new Uri.Builder();
localBuilder.scheme("content");
localBuilder.authority("dismiss");
localBuilder.appendPath(String.valueOf(paramInt1));
localBuilder.appendPath(String.valueOf(paramInt3));
localBuilder.appendPath(str);
Intent localIntent = new Intent(paramContext, DismissRecommendationService.class);
localIntent.setData(localBuilder.build());
localIntent.putExtra("appWidgetId", paramInt1);
localIntent.putExtra("documentId", paramDocument.mDocument.docid);
localIntent.putExtra("dismissalUrl", str);
localIntent.putExtra("backendId", paramInt2);
return PendingIntent.getService(paramContext, 0, localIntent, 0);
}
示例15: a
import android.net.Uri.Builder; //导入依赖的package包/类
private static Uri.Builder a(Context paramContext, Uri.Builder paramBuilder)
{
String str1;
try
{
paramBuilder.appendQueryParameter("version", String.valueOf(paramContext.getPackageManager().getPackageInfo(paramContext.getApplicationInfo().packageName, 0).versionCode));
return paramBuilder;
}
catch (PackageManager.NameNotFoundException localNameNotFoundException)
{
while (!Log.isLoggable("HelpUriGenerator", 6)) {}
str1 = String.valueOf(paramContext.getApplicationInfo().packageName);
if (str1.length() == 0) {}
}
for (String str2 = "Error finding package ".concat(str1);; str2 = new String("Error finding package "))
{
Log.e("HelpUriGenerator", str2);
return paramBuilder;
}
}