本文整理匯總了Java中android.net.Uri.parse方法的典型用法代碼示例。如果您正苦於以下問題:Java Uri.parse方法的具體用法?Java Uri.parse怎麽用?Java Uri.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.net.Uri
的用法示例。
在下文中一共展示了Uri.parse方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onClick
import android.net.Uri; //導入方法依賴的package包/類
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.rl_grade:
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri;
if (checkMarketInstall()) {
uri = Uri.parse("market://details?id=com.lingju.assistant");
intent.setPackage(pkgs[0]);
} else {
uri = Uri.parse("http://android.myapp.com/myapp/detail.htm?apkName=com.lingju.assistant");
}
intent.setData(uri);
startActivity(intent);
break;
case R.id.rl_feedback:
startActivity(new Intent(this, FeedbackActivity.class));
break;
case R.id.rl_about:
startActivity(new Intent(this, AboutLJActivity.class));
break;
case R.id.rl_connect:
startActivity(new Intent(this, ConnectUsActivity.class));
break;
}
goInto();
}
示例2: openLocationInMap
import android.net.Uri; //導入方法依賴的package包/類
/**
* This method uses the URI scheme for showing a location found on a map in conjunction with
* an implicit Intent. This super-handy intent is detailed in the "Common Intents" page of
* Android's developer site:
*
* @see "http://developer.android.com/guide/components/intents-common.html#Maps"
* <p>
* Protip: Hold Command on Mac or Control on Windows and click that link to automagically
* open the Common Intents page
*/
private void openLocationInMap() {
String addressString = SunshinePreferences.getPreferredWeatherLocation(this);
Uri geoLocation = Uri.parse("geo:0,0?q=" + addressString);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(geoLocation);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
} else {
Log.d(TAG, "Couldn't call " + geoLocation.toString() + ", no receiving apps installed!");
}
}
示例3: onWatchedButtonClicked
import android.net.Uri; //導入方法依賴的package包/類
@OnClick(R.id.fab_call)
public void onWatchedButtonClicked() {
if (ContextCompat.checkSelfPermission(getActivity(),
android.Manifest.permission.CALL_PHONE)
!= PackageManager.PERMISSION_GRANTED) {
if
(ActivityCompat.shouldShowRequestPermissionRationale(getActivity(),
android.Manifest.permission.CALL_PHONE)) {
Toast.makeText(getActivity(), "Its Necessary To Call", Toast.LENGTH_LONG).show();
ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.CALL_PHONE},
MY_PERMISSIONS_REQUEST_CALL_PHONE);
} else {
ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.CALL_PHONE},
MY_PERMISSIONS_REQUEST_CALL_PHONE);
}
} else {
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + seller.getPhone()));
startActivity(intent);
}
}
示例4: readEntity
import android.net.Uri; //導入方法依賴的package包/類
/** @inheritdoc */
@Override
public GroupMember readEntity(Cursor cursor, int offset) {
GroupMember entity = new GroupMember( //
cursor.getString(offset + 0), // groupId
cursor.getString(offset + 1), // userId
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // name
cursor.isNull(offset + 3) ? null : Uri.parse(cursor.getString(offset + 3)), // portraitUri
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // displayName
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // nameSpelling
cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // displayNameSpelling
cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // groupName
cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // groupNameSpelling
cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9) // groupPortraitUri
);
return entity;
}
示例5: checkFileUriDestination
import android.net.Uri; //導入方法依賴的package包/類
/**
* Check that the file URI provided for DESTINATION_FILE_URI is valid.
*/
private void checkFileUriDestination(ContentValues values) {
String fileUri = values.getAsString(Downloads.Impl.COLUMN_FILE_NAME_HINT);
if (fileUri == null) {
throw new IllegalArgumentException(
"DESTINATION_FILE_URI must include a file URI under COLUMN_FILE_NAME_HINT");
}
Uri uri = Uri.parse(fileUri);
String scheme = uri.getScheme();
if (scheme == null || !scheme.equals("file")) {
throw new IllegalArgumentException("Not a file URI: " + uri);
}
final String path = uri.getPath();
if (path == null) {
throw new IllegalArgumentException("Invalid file URI: " + uri);
}
final File file = new File(path);
if (!PermissionChecker.writeExternalStoragePermission(getContext())) {
throw new SecurityException("Unsupported path " + file);
}
}
示例6: rateApplication
import android.net.Uri; //導入方法依賴的package包/類
@Override public void rateApplication() {
Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY
| Intent.FLAG_ACTIVITY_NEW_DOCUMENT
| Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
} else {
goToMarket.addFlags(
Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
}
try {
settingFlowListener.startActivity(goToMarket);
} catch (ActivityNotFoundException e) {
settingFlowListener.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(
"http://play.google.com/store/apps/details?id=" + context.getPackageName())));
}
}
示例7: onCreate
import android.net.Uri; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
String url = AppConfig.getLaunchUrl();
if (!TextUtils.isEmpty(url)) {
Intent intent = new Intent(Intent.ACTION_VIEW);
String scheme = Uri.parse(url).getScheme();
StringBuilder builder = new StringBuilder();
if (TextUtils.equals("file", scheme)) {
intent.putExtra("isLocal", true);
} else if (!TextUtils.equals("http", scheme) && !TextUtils.equals("https", scheme)) {
builder.append("http:");
}
builder.append(url);
Uri uri = Uri.parse(builder.toString());
intent.setData(uri);
intent.addCategory("com.instapp.natex.android.intent.category.WEEX");
intent.setPackage(getPackageName());
startActivity(intent);
finish();
}
}
示例8: getUri
import android.net.Uri; //導入方法依賴的package包/類
public static Uri getUri(String input) {
Matcher matcher = hostmask.matcher(input);
if (!matcher.matches())
return null;
StringBuilder sb = new StringBuilder();
sb.append(PROTOCOL)
.append("://")
.append(Uri.encode(matcher.group(1)))
.append('@')
.append(Uri.encode(matcher.group(2)));
String portString = matcher.group(6);
int port = DEFAULT_PORT;
if (portString != null) {
try {
port = Integer.parseInt(portString);
if (port < 1 || port > 65535) {
port = DEFAULT_PORT;
}
} catch (NumberFormatException nfe) {
// Keep the default port
}
}
if (port != DEFAULT_PORT) {
sb.append(':')
.append(port);
}
sb.append("/#")
.append(Uri.encode(input));
Uri uri = Uri.parse(sb.toString());
return uri;
}
示例9: gotoPlayStore
import android.net.Uri; //導入方法依賴的package包/類
public static void gotoPlayStore(Activity context, String APP_ID, int request) {
Uri uri = Uri.parse("market://details?id=" + APP_ID);
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
// To count with Play market backstack, After pressing back button,
// to taken back to our application, we need to add following flags to intent.
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
try {
context.startActivity(goToMarket);
} catch (ActivityNotFoundException e) {
Uri link = Uri.parse("http://play.google.com/store/apps/details?id=" + APP_ID);
Intent intent = new Intent(Intent.ACTION_VIEW, link);
context.startActivityForResult(intent, request);
}
}
示例10: push
import android.net.Uri; //導入方法依賴的package包/類
@JSMethod(uiThread = true)
public void push(String param, JSCallback callback) {
if (!TextUtils.isEmpty(param)) {
if (WXSDKEngine.getActivityNavBarSetter() != null) {
if (WXSDKEngine.getActivityNavBarSetter().push(param)) {
callback.invoke(MSG_SUCCESS);
return;
}
}
try {
JSONObject jsonObject = JSON.parseObject(param);
String url = jsonObject.getString(URL);
if (!TextUtils.isEmpty(url)) {
Uri rawUri = Uri.parse(url);
String scheme = rawUri.getScheme();
Uri.Builder builder = rawUri.buildUpon();
if (TextUtils.isEmpty(scheme)) {
builder.scheme(Constants.Scheme.HTTP);
}
Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
intent.addCategory(WEEX);
intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId());
mWXSDKInstance.getContext().startActivity(intent);
callback.invoke(MSG_SUCCESS);
}
} catch (Exception e) {
WXLogUtils.eTag(TAG, e);
callback.invoke(MSG_FAILED);
}
}
callback.invoke(MSG_FAILED);
}
示例11: createRank
import android.net.Uri; //導入方法依賴的package包/類
private void createRank() {
Rank rank = new Rank();
User user = BmobUser.getCurrentUser(User.class);
rank.setTitle("測試");
Uri uri = Uri.parse("content://media/external/images/media/246751");
// File file = new File("content://media/external/images/media/246751");
// // File file1 = new File("")
// BmobFile bfile = new BmobFile(file);
// rank.setImage(bfile);
rank.setNo1(user);
rank.setNo2(user);
rank.setNo3(user);
rank.setNo4(user);
rank.setNo5(user);
rank.setNo6(user);
rank.setNo7(user);
rank.setNo8(user);
rank.setNo9(user);
rank.setNo10(user);
rank.save(new SaveListener<String>() {
@Override
public void done(String s, BmobException e) {
if (e == null) {
showToast("保存成功");
} else {
showToast("保存失敗" + e.getMessage() + e.getErrorCode());
}
}
});
}
示例12: getRealPathFromURI
import android.net.Uri; //導入方法依賴的package包/類
public String getRealPathFromURI(Context context, String contentURI) {
Uri contentUri = Uri.parse(contentURI);
Cursor cursor = context.getContentResolver().query(contentUri, null, null, null, null);
if (cursor == null) {
return contentUri.getPath();
} else {
cursor.moveToFirst();
int index = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
return cursor.getString(index);
}
}
示例13: getString
import android.net.Uri; //導入方法依賴的package包/類
public static String getString(String name, String defaultValue) {
SharedPreferences sp = getSP(name);
if (sp == null) {
ContentResolver cr = mContext.getContentResolver();
Uri uri = Uri.parse(CONTENT_URI + SEPARATOR + TYPE_STRING + SEPARATOR + name);
String rtn = cr.getType(uri);
if (rtn == null || rtn.equals(NULL_STRING)) {
return defaultValue;
}
return rtn;
} else {
return sp.getString(name, defaultValue);
}
}
示例14: setupMediaPlayer
import android.net.Uri; //導入方法依賴的package包/類
public void setupMediaPlayer() {
DataSource.Factory dsf = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "R/a/dio-Android-App"));
ExtractorsFactory extractors = new DefaultExtractorsFactory();
MediaSource audioSource = new ExtractorMediaSource(Uri.parse(radio_url), dsf, extractors, null, null);
if(sep != null)
sep.prepare(audioSource);
}
示例15: genContentUri
import android.net.Uri; //導入方法依賴的package包/類
/**
* The content:// style URL for this table.
*/
public static final Uri genContentUri(Context context) {
return Uri.parse(ProviderUtils.SCHEME + getAuthority(context) + "/"
+ PATH_HISTORY);
}