當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。