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


Java Uri.encode方法代码示例

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


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

示例1: forwardCallsIfBusy

import android.net.Uri; //导入方法依赖的package包/类
@ReactMethod
public void forwardCallsIfBusy(String phoneNumber) {
  String uri = "tel:**67*" + Uri.encode(phoneNumber+"#");
  Intent intent = new Intent(Intent.ACTION_CALL);
  intent.setData(Uri.parse(uri));
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  this.reactContext.startActivity(intent);
}
 
开发者ID:himelbrand,项目名称:react-native-forward-calls,代码行数:9,代码来源:RNForwardCallsModule.java

示例2: immediatePhoneCall

import android.net.Uri; //导入方法依赖的package包/类
@ReactMethod
public void immediatePhoneCall(String number) {
    number = Uri.encode(number);
    String url = "tel:" + number;
    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(url));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    this.reactContext.startActivity(intent);
}
 
开发者ID:wumke,项目名称:react-native-immediate-phone-call,代码行数:9,代码来源:RNImmediatePhoneCallModule.java

示例3: encodeUri

import android.net.Uri; //导入方法依赖的package包/类
public static Uri encodeUri(Uri uri) {
    String uriString = uri.toString();
    String uriEncodedString ="";
    if(uri.getScheme()!=null) {
        uriEncodedString += uri.getScheme() + "://";
        uriString = uriString.substring((uri.getScheme() + "://").length());
    }
    int i= 0;
    for(String seg : uriString.split("/")){ //split instead of using uri. get path segments because when weird caracters such as # %, path segments don't work properly
        seg = seg.replace("/","");
        if(i!=0||uriString.startsWith("/"))
            uriEncodedString+="/";
        uriEncodedString+=Uri.encode(seg);
        i++;
    }
    if(uriEncodedString.startsWith("//"))
        uriEncodedString = uriEncodedString.substring(1);
    return Uri.parse(uriEncodedString);
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:20,代码来源:Utils.java

示例4: cancelIfBusy

import android.net.Uri; //导入方法依赖的package包/类
@ReactMethod
public void cancelIfBusy() {
    String uri = "tel:" + Uri.encode("##67#");
    Intent intent = new Intent(Intent.ACTION_CALL);
    intent.setData(Uri.parse(uri));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    this.reactContext.startActivity(intent);
}
 
开发者ID:himelbrand,项目名称:react-native-forward-calls,代码行数:9,代码来源:RNForwardCallsModule.java

示例5: shareTwitter

import android.net.Uri; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void shareTwitter() {
    Intent twitterIntent = new Intent();
    twitterIntent.setType("text/plain");
    twitterIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.like_text));

    final PackageManager packageManager = getActivity().getPackageManager();
    List<ResolveInfo> list = packageManager.queryIntentActivities(twitterIntent, PackageManager.MATCH_DEFAULT_ONLY);

    boolean found = false;
    for (ResolveInfo resolveInfo : list) {
        String p = resolveInfo.activityInfo.packageName;
        if (p != null && p.startsWith("com.twitter.android")) {
            found = true;
            twitterIntent.setPackage(p);
            startActivity(twitterIntent);

            ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER)
                    .send(new HitBuilders.EventBuilder().setCategory("Sharing").setAction("Twitter").setLabel("App").build());
        }
    }

    if (!found) {
        ProgressDialog progressDialog = new ProgressDialog(getActivity());

        TwitterShare d = new TwitterShare(
                getActivity(), progressDialog,
                "http://twitter.com/share?text=" + Uri.encode(getString(R.string.like_text_twitter)) + "&url=" + Uri.parse(getString(R.string.like_url)));
        d.show();

        progressDialog.setMessage(getString(R.string.text_loading));
        progressDialog.setCancelable(true);
        progressDialog.show();

        ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER)
                .send(new HitBuilders.EventBuilder().setCategory("Sharing").setAction("Twitter").setLabel("Web").build());
    }
}
 
开发者ID:dmllr,项目名称:IdealMedia,代码行数:39,代码来源:NavigationDrawerFragment.java

示例6: cancelAllConditional

import android.net.Uri; //导入方法依赖的package包/类
@ReactMethod
public void cancelAllConditional() {
    String uri = "tel:" + Uri.encode("##002#");
    Intent intent = new Intent(Intent.ACTION_CALL);
    intent.setData(Uri.parse(uri));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    this.reactContext.startActivity(intent);
}
 
开发者ID:himelbrand,项目名称:react-native-forward-calls,代码行数:9,代码来源:RNForwardCallsModule.java

示例7: getSafeStringUrl

import android.net.Uri; //导入方法依赖的package包/类
private String getSafeStringUrl() {
  if (TextUtils.isEmpty(safeStringUrl)) {
    String unsafeStringUrl = stringUrl;
    if (TextUtils.isEmpty(unsafeStringUrl)) {
      unsafeStringUrl = url.toString();
    }
    safeStringUrl = Uri.encode(unsafeStringUrl, ALLOWED_URI_CHARS);
  }
  return safeStringUrl;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:GlideUrl.java

示例8: getParentUriStringAndFileName

import android.net.Uri; //导入方法依赖的package包/类
public static Pair<String, String>  getParentUriStringAndFileName(Uri uri){
    //try to get parent
    String last = uri.getLastPathSegment();
    String[] parts = last.split(":");
    int i = 0;
    String parentLastPart = "";
    String filename="";
    parentLastPart+=parts[0]+ Uri.encode(":");
    if(parts.length>1&&parts[1]!=null) {
        parts = parts[1].split("/");
        for (String part : parts) {
            i++;
            if (i != parts.length) {
                parentLastPart += Uri.encode(part);
                if (i != parts.length-1)
                    parentLastPart += Uri.encode("/");

            } else
                filename = part;
        }
    }
    else
        filename = parts[0] ;
    Uri withoutLastPath = Utils.removeLastSegment(uri);
    return new Pair<>(Uri.withAppendedPath(withoutLastPath, parentLastPart).toString(),filename);

}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:28,代码来源:DocumentUriBuilder.java

示例9: encodeUser

import android.net.Uri; //导入方法依赖的package包/类
public static String encodeUser(String user) {
    //user             =  1*( unreserved / escaped / user-unreserved )
    //user-unreserved  =  "&" / "=" / "+" / "$" / "," / ";" / "?" / "/"
    //unreserved  =  alphanum / mark
    //mark        =  "-" / "_" / "." / "!" / "~" / "*" / "'" / "(" / ")"
    return Uri.encode(user, "&=+$,;?/-_.!~*'()");
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:8,代码来源:SipUri.java

示例10: unconditionalForwarding

import android.net.Uri; //导入方法依赖的package包/类
@ReactMethod
public void unconditionalForwarding(String phoneNumber) {
  String uri = "tel:**21*" + Uri.encode(phoneNumber+"#");
  Intent intent = new Intent(Intent.ACTION_CALL);
  intent.setData(Uri.parse(uri));
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  this.reactContext.startActivity(intent);
}
 
开发者ID:himelbrand,项目名称:react-native-forward-calls,代码行数:9,代码来源:RNForwardCallsModule.java

示例11: generarQR

import android.net.Uri; //导入方法依赖的package包/类
private void generarQR(String dato, ImageView objeto) throws WriterException {
    Writer generador = new QRCodeWriter();
    String datoFinal = Uri.encode(dato, getString(R.string.fragment_detalle_promocion_utf8));

    BitMatrix bm = generador.encode(datoFinal, BarcodeFormat.QR_CODE, 150, 150);
    imagenBitMap = Bitmap.createBitmap(150, 150, Bitmap.Config.ARGB_8888);

    for (int i = 0; i < 150; i++) { //width
        for (int j = 0; j < 150; j++) { //height
            imagenBitMap.setPixel(i, j, bm.get(i, j) ? Color.BLACK : Color.WHITE);
        }
    }

    if (imagenBitMap != null) {
        objeto.setImageBitmap(imagenBitMap);
    }
}
 
开发者ID:ur13l,项目名称:Guanajoven,代码行数:18,代码来源:DetallePromocionFragment.java

示例12: generarQR

import android.net.Uri; //导入方法依赖的package包/类
private void generarQR(String dato, ImageView objeto) throws WriterException {
    Writer generador = new QRCodeWriter();
    String datoFinal = Uri.encode(dato, getString(R.string.fragment_idguanajoven_utf8));

    BitMatrix bm = generador.encode(datoFinal, BarcodeFormat.QR_CODE, 150, 150);
    imagenBitMap = Bitmap.createBitmap(150, 150, Bitmap.Config.ARGB_8888);

    for (int i = 0; i < 150; i++) { //width
        for (int j = 0; j < 150; j++) { //height
            imagenBitMap.setPixel(i, j, bm.get(i, j) ? Color.BLACK : Color.WHITE);
        }
    }

    if (imagenBitMap != null) {
        objeto.setImageBitmap(imagenBitMap);
    }
}
 
开发者ID:ur13l,项目名称:Guanajoven,代码行数:18,代码来源:IDGuanajovenFragment.java

示例13: sendMail

import android.net.Uri; //导入方法依赖的package包/类
private void sendMail() {
    String mailto = "mailto:" + getResources().getString(R.string.email_mailto) +
            "?subject=" + Uri.encode(getResources().getString(R.string.email_subject)) +
            "&body=" + Uri.encode("");

    Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
    emailIntent.setData(Uri.parse(mailto));
    startActivity(Intent.createChooser(emailIntent, "Send Email"));
}
 
开发者ID:ROKOLabs,项目名称:ROKOmoji.Emoji.Keyboard.App-Android,代码行数:10,代码来源:LinksFragment.java

示例14: cancelCustomForward

import android.net.Uri; //导入方法依赖的package包/类
@ReactMethod
public void cancelCustomForward(String code) {
    String uri = "tel:" + Uri.encode(code);
    Intent intent = new Intent(Intent.ACTION_CALL);
    intent.setData(Uri.parse(uri));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    this.reactContext.startActivity(intent);
}
 
开发者ID:himelbrand,项目名称:react-native-forward-calls,代码行数:9,代码来源:RNForwardCallsModule.java

示例15: createIntentFromSuggestion

import android.net.Uri; //导入方法依赖的package包/类
private Intent createIntentFromSuggestion(Cursor c, int actionKey, String actionMsg) {
    try {
        String action = SuggestionsAdapter.getColumnString(c, "suggest_intent_action");
        if (action == null && VERSION.SDK_INT >= 8) {
            action = this.mSearchable.getSuggestIntentAction();
        }
        if (action == null) {
            action = "android.intent.action.SEARCH";
        }
        String data = SuggestionsAdapter.getColumnString(c, "suggest_intent_data");
        if (IS_AT_LEAST_FROYO && data == null) {
            data = this.mSearchable.getSuggestIntentData();
        }
        if (data != null) {
            String id = SuggestionsAdapter.getColumnString(c, "suggest_intent_data_id");
            if (id != null) {
                data = data + "/" + Uri.encode(id);
            }
        }
        return createIntent(action, data == null ? null : Uri.parse(data), SuggestionsAdapter.getColumnString(c, "suggest_intent_extra_data"), SuggestionsAdapter.getColumnString(c, "suggest_intent_query"), actionKey, actionMsg);
    } catch (RuntimeException e) {
        int rowNum;
        try {
            rowNum = c.getPosition();
        } catch (RuntimeException e2) {
            rowNum = -1;
        }
        Log.w(LOG_TAG, "Search suggestions cursor at row " + rowNum + " returned exception.", e);
        return null;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:32,代码来源:SearchView.java


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