本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
}
示例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);
}
示例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;
}
示例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);
}
示例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, "&=+$,;?/-_.!~*'()");
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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"));
}
示例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);
}
示例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;
}
}