本文整理了Java中android.net.Uri.fromParts()
方法的一些代码示例,展示了Uri.fromParts()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Uri.fromParts()
方法的具体详情如下:
包路径:android.net.Uri
类名称:Uri
方法名:fromParts
[英]Creates an opaque Uri from the given components. Encodes the ssp which means this method cannot be used to create hierarchical URIs.
[中]从给定组件创建不透明Uri。对ssp进行编码,这意味着此方法不能用于创建分层URI。
代码示例来源:origin: robolectric/robolectric
private boolean isPackageRequiredUninstaller(String packageName) {
final Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setData(Uri.fromParts(PACKAGE_SCHEME, "foo.bar", null));
ResolveInfo info =
resolveActivity(
intent,
PackageManager.MATCH_SYSTEM_ONLY
| PackageManager.MATCH_DIRECT_BOOT_AWARE
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE);
return info != null && packageName.equals(info.activityInfo.packageName);
}
代码示例来源:origin: jokermonn/permissions4m
@Override
public Intent settingIntent() {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
intent.setData(uri);
return intent;
}
}
代码示例来源:origin: android-hacker/VirtualXposed
void showAppDetails(ResolveInfo ri) {
Intent in = new Intent().setAction("android.settings.APPLICATION_DETAILS_SETTINGS")
.setData(Uri.fromParts("package", ri.activityInfo.packageName, null))
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(in);
}
代码示例来源:origin: android-hacker/VirtualXposed
private void sendFirstLaunchBroadcast(PackageSetting ps, int userId) {
Intent intent = new Intent(Intent.ACTION_PACKAGE_FIRST_LAUNCH, Uri.fromParts("package", ps.packageName, null));
intent.setPackage(ps.packageName);
intent.putExtra(Intent.EXTRA_UID, VUserHandle.getUid(ps.appId, userId));
intent.putExtra("android.intent.extra.user_handle", userId);
sendBroadcastAsUser(intent, null);
}
代码示例来源:origin: PhilJay/MPAndroidChart
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent i;
switch (item.getItemId()) {
case R.id.viewGithub:
i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart"));
startActivity(i);
break;
case R.id.report:
i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", "philjay.librarysup@gmail.com", null));
i.putExtra(Intent.EXTRA_SUBJECT, "MPAndroidChart Issue");
i.putExtra(Intent.EXTRA_TEXT, "Your error report here...");
startActivity(Intent.createChooser(i, "Report Problem"));
break;
case R.id.website:
i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("http://at.linkedin.com/in/philippjahoda"));
startActivity(i);
break;
}
return true;
}
}
代码示例来源:origin: ACRA/acra
/**
* Builds an intent used to resolve email clients and to send reports without attachments or as fallback if no attachments are supported
*
* @param subject the message subject
* @param body the message body
* @return email intent
*/
@NonNull
protected Intent buildResolveIntent(@NonNull String subject, @NonNull String body) {
final Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.fromParts("mailto", mailConfig.mailTo(), null));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, body);
return intent;
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
/**
* 启动app设置授权界面
* @param context
*/
public static void startSettingIntent(Context context) {
Intent localIntent = new Intent();
localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (Build.VERSION.SDK_INT >= 9) {
localIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
localIntent.setData(Uri.fromParts("package", context.getPackageName(),null));
} else if (Build.VERSION.SDK_INT <= 8) {
localIntent.setAction(Intent.ACTION_VIEW);
localIntent.setClassName("com.android.settings","com.android.settings.InstalledAppDetails");
localIntent.putExtra("com.android.settings.ApplicationPkgName", context.getPackageName());
}
context.startActivity(localIntent);
}
}
代码示例来源:origin: yhaolpz/FloatWindow
private static void reqForMiui5(Context context) {
String packageName = context.getPackageName();
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", packageName, null);
intent.setData(uri);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (isIntentAvailable(intent, context)) {
context.startActivity(intent);
} else {
LogUtil.e("intent is not available!");
}
}
代码示例来源:origin: cymcsg/UltimateAndroid
/**
* start InstalledAppDetails Activity
*
* @param context
* @param packageName
*/
public static void startInstalledAppDetails(Context context, String packageName) {
Intent intent = new Intent();
int sdkVersion = Build.VERSION.SDK_INT;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.fromParts("package", packageName, null));
} else {
intent.setAction(Intent.ACTION_VIEW);
intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
intent.putExtra((sdkVersion == Build.VERSION_CODES.FROYO ? "pkg"
: "com.android.settings.ApplicationPkgName"), packageName);
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
代码示例来源:origin: googlesamples/easypermissions
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == Dialog.BUTTON_POSITIVE) {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
.setData(Uri.fromParts("package", getPackageName(), null));
intent.addFlags(mIntentFlags);
startActivityForResult(intent, APP_SETTINGS_RC);
} else if (which == Dialog.BUTTON_NEGATIVE) {
setResult(Activity.RESULT_CANCELED);
finish();
} else {
throw new IllegalStateException("Unknown button type: " + which);
}
}
代码示例来源:origin: k9mail/k-9
/**
* Start the activity to add information to an existing contact or add a
* new one.
*
* @param email An {@link Address} instance containing the email address
* of the entity you want to add to the contacts. Optionally
* the instance also contains the (display) name of that
* entity.
*/
public void createContact(final Address email) {
final Uri contactUri = Uri.fromParts("mailto", email.getAddress(), null);
final Intent contactIntent = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT);
contactIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
contactIntent.setData(contactUri);
// Pass along full email string for possible create dialog
contactIntent.putExtra(ContactsContract.Intents.EXTRA_CREATE_DESCRIPTION,
email.toString());
// Only provide personal name hint if we have one
final String senderPersonal = email.getPersonal();
if (senderPersonal != null) {
contactIntent.putExtra(ContactsContract.Intents.Insert.NAME, senderPersonal);
}
mContext.startActivity(contactIntent);
clearCache();
}
代码示例来源:origin: k9mail/k-9
case TOKEN_EMAIL_LOOKUP_AND_TRIGGER:
trigger = true;
createUri = Uri.fromParts("mailto",
extras.getString(EXTRA_URI_CONTENT), null);
代码示例来源:origin: ankidroid/Anki-Android
public void onRequestPermissionsResult (int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == REQUEST_STORAGE_PERMISSION && permissions.length == 1) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
invalidateOptionsMenu();
showStartupScreensAndDialogs(AnkiDroidApp.getSharedPrefs(this), 0);
} else {
// User denied access to the SD card so show error toast and finish activity
Toast.makeText(this, R.string.directory_inaccessible, Toast.LENGTH_LONG).show();
finishWithoutAnimation();
// Open the Android settings page for our app so that the user can grant the missing permission
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivityWithoutAnimation(intent);
}
}
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(minSdk = O) // The setter on the real manager was added in O
public void shouldSetVoicemailRingtoneUri() {
PhoneAccountHandle phoneAccountHandle =
new PhoneAccountHandle(
new ComponentName(ApplicationProvider.getApplicationContext(), Object.class), "handle");
Uri ringtoneUri = Uri.fromParts("file", "ringtone.mp3", /* fragment = */ null);
// Note: Using the real manager to set, instead of the shadow.
telephonyManager.setVoicemailRingtoneUri(phoneAccountHandle, ringtoneUri);
assertEquals(ringtoneUri, telephonyManager.getVoicemailRingtoneUri(phoneAccountHandle));
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(minSdk = N)
public void shouldGiveVoicemailRingtoneUri() {
PhoneAccountHandle phoneAccountHandle =
new PhoneAccountHandle(
new ComponentName(ApplicationProvider.getApplicationContext(), Object.class), "handle");
Uri ringtoneUri = Uri.fromParts("file", "ringtone.mp3", /* fragment = */ null);
shadowOf(telephonyManager).setVoicemailRingtoneUri(phoneAccountHandle, ringtoneUri);
assertEquals(ringtoneUri, telephonyManager.getVoicemailRingtoneUri(phoneAccountHandle));
}
代码示例来源:origin: Neamar/KISS
/**
* Open an activity to uninstall the current package
*/
private void launchUninstall(Context context, AppPojo app) {
Intent intent = new Intent(Intent.ACTION_DELETE,
Uri.fromParts("package", app.packageName, null));
context.startActivity(intent);
}
代码示例来源:origin: TakWolf/CNode-Material-Design
@Override
public void onClick(DialogInterface dialog, int which) {
activity.startActivity(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", activity.getPackageName(), null)));
}
代码示例来源:origin: Neamar/KISS
/**
* Open an activity displaying details regarding the current package
*/
private void launchAppDetails(Context context, AppPojo app) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
LauncherApps launcher = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
assert launcher != null;
launcher.startAppDetailsActivity(className, appPojo.userHandle.getRealHandle(), null, null);
} else {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts("package", app.packageName, null));
context.startActivity(intent);
}
}
代码示例来源:origin: recruit-lifestyle/FloatingView
@Override
public void onClick(View v) {
// メールアプリの起動
final Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", getString(R.string.mail_address), null));
intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.mail_title));
intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.mail_content));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
});
代码示例来源:origin: chat-sdk/chat-sdk-android
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.contact_developer) {
String emailAddress = ChatSDK.config().contactDeveloperEmailAddress;
String subject = ChatSDK.config().contactDeveloperEmailSubject;
String dialogTitle = ChatSDK.config().contactDeveloperDialogTitle;
if(StringUtils.isNotEmpty(emailAddress))
{
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", emailAddress, null));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
startActivity(Intent.createChooser(emailIntent, dialogTitle));
}
return true;
}
return super.onOptionsItemSelected(item);
}
内容来源于网络,如有侵权,请联系作者删除!