本文整理了Java中android.content.Intent.parseUri()
方法的一些代码示例,展示了Intent.parseUri()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.parseUri()
方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:parseUri
暂无
代码示例来源:origin: Justson/AgentWeb
private int queryActiviesNumber(String url) {
try {
if (mWeakReference.get() == null) {
return 0;
}
Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
PackageManager mPackageManager = mWeakReference.get().getPackageManager();
List<ResolveInfo> mResolveInfos = mPackageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
return mResolveInfos == null ? 0 : mResolveInfos.size();
} catch (URISyntaxException ignore) {
if (LogUtils.isDebug()) {
ignore.printStackTrace();
}
return 0;
}
}
代码示例来源:origin: Justson/AgentWeb
private boolean lookup(String url) {
try {
Intent intent;
Activity mActivity = null;
if ((mActivity = mWeakReference.get()) == null) {
return true;
}
PackageManager packageManager = mActivity.getPackageManager();
intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
ResolveInfo info = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
// 跳到该应用
if (info != null) {
mActivity.startActivity(intent);
return true;
}
} catch (Throwable ignore) {
if (LogUtils.isDebug()) {
ignore.printStackTrace();
}
}
return false;
}
代码示例来源:origin: android-hacker/VirtualXposed
if (splashUri != null) {
try {
splashIntent = Intent.parseUri(splashUri, 0);
} catch (URISyntaxException e) {
e.printStackTrace();
targetIntent = Intent.parseUri(targetUri, 0);
} catch (URISyntaxException e) {
e.printStackTrace();
代码示例来源:origin: ankidroid/Anki-Android
try {
if (url.startsWith("intent:")) {
intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
} else if (url.startsWith("android-app:")) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
intent = Intent.parseUri(url, 0);
intent.setData(null);
intent.setPackage(Uri.parse(url).getHost());
} else {
intent = Intent.parseUri(url, Intent.URI_ANDROID_APP_SCHEME);
代码示例来源:origin: UweTrottmann/SeriesGuide
/**
* Deserializes a {@link Bundle} into a {@link Action} object.
*/
public static Action fromBundle(Bundle bundle) {
String title = bundle.getString(KEY_TITLE);
if (TextUtils.isEmpty(title)) {
return null;
}
int entityIdentifier = bundle.getInt(KEY_ENTITY_IDENTIFIER);
if (entityIdentifier <= 0) {
return null;
}
Builder builder = new Builder(title, entityIdentifier);
try {
String viewIntent = bundle.getString(KEY_VIEW_INTENT);
if (!TextUtils.isEmpty(viewIntent)) {
builder.viewIntent(Intent.parseUri(viewIntent, Intent.URI_INTENT_SCHEME));
}
} catch (URISyntaxException ignored) {
}
return builder.build();
}
代码示例来源:origin: UweTrottmann/SeriesGuide
/**
* Deserializes a {@link JSONObject} into an {@link Action} object.
*/
public static Action fromJson(JSONObject jsonObject) throws JSONException {
String title = jsonObject.optString(KEY_TITLE);
if (TextUtils.isEmpty(title)) {
return null;
}
int entityIdentifier = jsonObject.optInt(KEY_ENTITY_IDENTIFIER);
if (entityIdentifier <= 0) {
return null;
}
Builder builder = new Builder(title, entityIdentifier);
try {
String viewIntent = jsonObject.optString(KEY_VIEW_INTENT);
if (!TextUtils.isEmpty(viewIntent)) {
builder.viewIntent(Intent.parseUri(viewIntent, Intent.URI_INTENT_SCHEME));
}
} catch (URISyntaxException ignored) {
}
return builder.build();
}
}
代码示例来源:origin: Neamar/KISS
@Override
protected void doLaunch(Context context, View v) {
if (shortcutPojo.isOreoShortcut()) {
// Oreo shortcuts
doOreoLaunch(context, v);
} else {
// Pre-oreo shortcuts
try {
Intent intent = Intent.parseUri(shortcutPojo.intentUri, 0);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
intent.setSourceBounds(v.getClipBounds());
}
context.startActivity(intent);
} catch (Exception e) {
// Application was just removed?
Toast.makeText(context, R.string.application_not_found, Toast.LENGTH_LONG).show();
}
}
}
代码示例来源:origin: Neamar/KISS
Drawable appDrawable = null;
try {
Intent intent = Intent.parseUri(shortcutPojo.intentUri, 0);
List<ResolveInfo> packages = packageManager.queryIntentActivities(intent, 0);
if (packages.size() > 0) {
代码示例来源:origin: Neamar/KISS
Intent intent = Intent.parseUri(intentUri, 0);
if (intent.getCategories() != null && intent.getCategories().contains(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(intent.getAction())) {
代码示例来源:origin: GoBelieveIO/im_android
public static void openBaidu(Context context, String poiname, double longitude, double latitude) {
try {
poiname = (poiname != null) ? poiname : "";
Intent intent = Intent.parseUri("intent://map/direction?" + "destination=latlng:" + latitude + "," + longitude + "|name:" + poiname, 0);
context.startActivity(intent);
} catch (URISyntaxException e) {
Log.e("intent", e.getMessage());
}
}
代码示例来源:origin: fookwood/Launcher3
@Override
protected Intent parseIntent(XmlResourceParser parser) {
String uri = null;
try {
uri = getAttributeValue(parser, ATTR_URI);
return Intent.parseUri(uri, 0);
} catch (URISyntaxException e) {
Log.w(TAG, "Shortcut has malformed uri: " + uri);
return null; // Oh well
}
}
}
代码示例来源:origin: fg607/RelaxFinger
public static void startActivity(Context activity,String intentUri) throws URISyntaxException,ActivityNotFoundException {
Intent intent = Intent.parseUri(intentUri,Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
if(intent!= null){
activity.startActivity(intent);
}else {
throw new ActivityNotFoundException();
}
}
代码示例来源:origin: klinker24/launcher3
@Override
protected Intent parseIntent(XmlResourceParser parser) {
String uri = null;
try {
uri = getAttributeValue(parser, ATTR_URI);
return Intent.parseUri(uri, 0);
} catch (URISyntaxException e) {
Log.w(TAG, "Shortcut has malformed uri: " + uri);
return null; // Oh well
}
}
}
代码示例来源:origin: enricocid/LaunchEnr
public Intent parseIntent() {
String intentDescription = getString(intentIndex);
try {
return TextUtils.isEmpty(intentDescription) ?
null : Intent.parseUri(intentDescription, 0);
} catch (URISyntaxException e) {
e.printStackTrace();
return null;
}
}
代码示例来源:origin: Coinomi/coinomi-android
static public void replyAddressRequest(Activity activity, CoinURI uri, WalletAccount pocket) throws CoinURIParseException {
try {
String uriString = uri.getAddressRequestUriResponse(pocket.getReceiveAddress()).toString();
Intent intent = Intent.parseUri(uriString, 0);
activity.startActivity(intent);
} catch (Exception e) {
// Should not happen
ACRA.getErrorReporter().handleSilentException(e);
Toast.makeText(activity, R.string.error_generic, Toast.LENGTH_LONG).show();
}
}
代码示例来源:origin: fookwood/Launcher3
/**
* Verifies if the intent should be restored.
*/
private void verifyIntent(String intentStr) throws Exception {
Intent intent = Intent.parseUri(intentStr, 0);
if (intent.getComponent() != null) {
verifyPackage(intent.getComponent().getPackageName());
} else if (intent.getPackage() != null) {
// Only verify package if the component was null.
verifyPackage(intent.getPackage());
}
}
代码示例来源:origin: enricocid/LaunchEnr
private Decoder(String encoded, Context context) throws JSONException, URISyntaxException {
super(encoded);
launcherIntent = Intent.parseUri(getString(LAUNCH_INTENT_KEY), 0);
user = has(USER_HANDLE_KEY) ? UserManagerCompat.getInstance(context)
.getUserForSerialNumber(getLong(USER_HANDLE_KEY))
: Process.myUserHandle();
if (user == null) {
throw new JSONException("Invalid user");
}
}
}
代码示例来源:origin: klinker24/launcher3
/**
* Verifies if the intent should be restored.
*/
private void verifyIntent(String intentStr) throws Exception {
Intent intent = Intent.parseUri(intentStr, 0);
if (intent.getComponent() != null) {
verifyPackage(intent.getComponent().getPackageName());
} else if (intent.getPackage() != null) {
// Only verify package if the component was null.
verifyPackage(intent.getPackage());
}
}
代码示例来源:origin: klinker24/Android-Blur-Launcher
/**
* Verifies if the intent should be restored.
*/
private void verifyIntent(String intentStr) throws Exception {
Intent intent = Intent.parseUri(intentStr, 0);
if (intent.getComponent() != null) {
verifyPackage(intent.getComponent().getPackageName());
} else if (intent.getPackage() != null) {
// Only verify package if the component was null.
verifyPackage(intent.getPackage());
}
}
代码示例来源:origin: enricocid/LaunchEnr
/**
* Verifies if the intent should be restored.
*/
private void verifyIntent(String intentStr) throws Exception {
Intent intent = Intent.parseUri(intentStr, 0);
if (intent.getComponent() != null) {
verifyPackage(intent.getComponent().getPackageName());
} else if (intent.getPackage() != null) {
// Only verify package if the component was null.
verifyPackage(intent.getPackage());
}
}
内容来源于网络,如有侵权,请联系作者删除!