Java Code Examples for android.net.Uri.Builder#appendQueryParameter()

The following examples show how to use android.net.Uri.Builder#appendQueryParameter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractContentProviderStub.java    From letv with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 2
Source File: AssistActivity.java    From letv with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: ShareRequestParam.java    From letv with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 4
Source File: Imps.java    From Zom-Android-XMPP with GNU General Public License v3.0 6 votes vote down vote up
public static boolean setEmptyPassphrase(Context ctx, boolean noCreate) {
    String pkey = "";

    Uri uri = Provider.CONTENT_URI_WITH_ACCOUNT;

    Builder builder = uri.buildUpon().appendQueryParameter(ImApp.CACHEWORD_PASSWORD_KEY, pkey);
    if (noCreate) {
        builder.appendQueryParameter(ImApp.NO_CREATE_KEY, "1");
    }
    uri = builder.build();

    Cursor cursor = ctx.getContentResolver().query(uri, null, null, null, null);
    if (cursor != null) {
        cursor.close();
        return true;
    }
    return false;
}
 
Example 5
Source File: WidgetRequestParam.java    From letv with Apache License 2.0 5 votes vote down vote up
private String buildUrl(String baseUrl) {
    Builder builder = Uri.parse(baseUrl).buildUpon();
    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(ShareRequestParam.REQ_PARAM_PACKAGENAME, this.mAppPackage);
    }
    if (!TextUtils.isEmpty(this.mHashKey)) {
        builder.appendQueryParameter(ShareRequestParam.REQ_PARAM_KEY_HASH, this.mHashKey);
    }
    if (!TextUtils.isEmpty(this.mAttentionFuid)) {
        builder.appendQueryParameter(REQ_PARAM_ATTENTION_FUID, this.mAttentionFuid);
    }
    if (!TextUtils.isEmpty(this.mCommentTopic)) {
        builder.appendQueryParameter(REQ_PARAM_COMMENT_TOPIC, this.mCommentTopic);
    }
    if (!TextUtils.isEmpty(this.mCommentContent)) {
        builder.appendQueryParameter(REQ_PARAM_COMMENT_CONTENT, this.mCommentContent);
    }
    if (!TextUtils.isEmpty(this.mCommentCategory)) {
        builder.appendQueryParameter(REQ_PARAM_COMMENT_CATEGORY, this.mCommentCategory);
    }
    return builder.build().toString();
}
 
Example 6
Source File: Imps.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isUnlocked(Context context)
{
    try {
        Cursor cursor = null;

        Uri uri = Imps.Provider.CONTENT_URI_WITH_ACCOUNT;

        Builder builder = uri.buildUpon();
        builder = builder.appendQueryParameter(ImApp.NO_CREATE_KEY, "1");

        uri = builder.build();

        cursor = context.getContentResolver().query(
                uri, null, null, null,
                null);

        if (cursor != null)
        {
            cursor.close();
            return true;
        }
        else
        {
            return false;
        }

    } catch (Exception e) {
        // Only complain if we thought this password should succeed

         Log.e(ImApp.LOG_TAG, e.getMessage(), e);

        // needs to be unlocked
        return false;
    }
}
 
Example 7
Source File: Imps.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isUnencrypted(Context context) {
    try {
        Cursor cursor = null;

        Uri uri = Imps.Provider.CONTENT_URI_WITH_ACCOUNT;

        Builder builder = uri.buildUpon();
        builder.appendQueryParameter(ImApp.CACHEWORD_PASSWORD_KEY, "");
        builder = builder.appendQueryParameter(ImApp.NO_CREATE_KEY, "1");

        uri = builder.build();

        cursor = context.getContentResolver().query(
                uri, null, Imps.Provider.CATEGORY + "=?" /* selection */,
                new String[] { ImApp.IMPS_CATEGORY } /* selection args */,
                null);

        if (cursor != null)
        {
           cursor.close();
            return true;
        }
        else
        {
            return false;
        }

    } catch (Exception e) {
        // Only complain if we thought this password should succeed

         Log.e(ImApp.LOG_TAG, e.getMessage(), e);

        // needs to be unlocked
        return false;
    }
}
 
Example 8
Source File: ProtocolBuilder.java    From letv with Apache License 2.0 4 votes vote down vote up
protected Builder append(Builder builder, String key, String value) {
    if (!(TextUtils.isEmpty(key) || TextUtils.isEmpty(value))) {
        builder.appendQueryParameter(key, value);
    }
    return builder;
}