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


Java Uri.parse方法代码示例

本文整理汇总了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();
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:28,代码来源:IntroduceActivity.java

示例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!");
    }
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:24,代码来源:MainActivity.java

示例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);
    }
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:23,代码来源:ProductDetailFragment.java

示例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;
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:18,代码来源:GroupMemberDao.java

示例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);
    }
}
 
开发者ID:limpoxe,项目名称:Android-DownloadManager,代码行数:25,代码来源:DownloadProvider.java

示例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())));
    }
}
 
开发者ID:riteshakya037,项目名称:Subs,代码行数:19,代码来源:SettingPresenterImpl.java

示例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();
  }

}
 
开发者ID:natjs,项目名称:nat-explorer,代码行数:27,代码来源:SplashActivity.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:40,代码来源:SSH.java

示例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);
    }
}
 
开发者ID:tranleduy2000,项目名称:floating_calc,代码行数:15,代码来源:StoreUtil.java

示例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);
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:36,代码来源:WXNavigatorModule.java

示例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());
                }
            }
        });
    }
 
开发者ID:HowieTianDev,项目名称:ChenYan,代码行数:32,代码来源:Main2Activity.java

示例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);
    }
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:12,代码来源:Comman.java

示例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);
    }
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:15,代码来源:SPHelper.java

示例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);
}
 
开发者ID:R-a-dio,项目名称:R-a-dio-Amazing-Android-App,代码行数:10,代码来源:RadioService.java

示例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);
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:8,代码来源:HistoryContract.java


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