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