Java Code Examples for android.net.Uri#fromParts()

The following examples show how to use android.net.Uri#fromParts() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppInfoUtils.java    From Bailan with Apache License 2.0 6 votes vote down vote up
public static void showInstalledAppDetails(Context context, String packageName) {
    Intent intent = new Intent();
    final int apiLevel = Build.VERSION.SDK_INT;
    if (apiLevel >= 9) { // 2.3(ApiLevel 9)以上,使用SDK提供的接口
        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        Uri uri = Uri.fromParts(SCHEME, packageName, null);
        intent.setData(uri);
    } else { // 2.3以下,使用非公开的接口(查看InstalledAppDetails源码)
        // 2.2和2.1中,InstalledAppDetails使用的APP_PKG_NAME不同。
        final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22
                : APP_PKG_NAME_21);
        intent.setAction(Intent.ACTION_VIEW);
        intent.setClassName(APP_DETAILS_PACKAGE_NAME,
                APP_DETAILS_CLASS_NAME);
        intent.putExtra(appPkgName, packageName);
    }
    context.startActivity(intent);
}
 
Example 2
Source File: AboutShortcuts.java    From prayer-times-android with Apache License 2.0 6 votes vote down vote up
public static void sendMail(@NonNull Context ctx) {
    Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "[email protected]", null));
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, ctx.getString(R.string.appName) + " (com.metinkaler.prayer)");
    String versionCode = "Undefined";
    String versionName = "Undefined";
    try {
        versionCode = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionCode + "";
        versionName = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionName + "";
    } catch (PackageManager.NameNotFoundException e) {
        Crashlytics.logException(e);
    }
    emailIntent.putExtra(Intent.EXTRA_TEXT,
            "===Device Information===" +
                    "\nUUID: " + Preferences.UUID.get() +
                    "\nManufacturer: " + Build.MANUFACTURER +
                    "\nModel: " + Build.MODEL +
                    "\nAndroid Version: " + Build.VERSION.RELEASE +
                    "\nApp Version Name: " + versionName +
                    "\nApp Version Code: " + versionCode +
                    "\n======================\n\n");
    ctx.startActivity(Intent.createChooser(emailIntent, ctx.getString(R.string.mail)));
}
 
Example 3
Source File: LauncherAppsCompatV16.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
public void showAppDetailsForProfile(ComponentName component, UserHandleCompat user) {
    String packageName = component.getPackageName();
    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
            Uri.fromParts("package", packageName, null));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK |
            Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    mContext.startActivity(intent, null);
}
 
Example 4
Source File: LibraryEmptyState.java    From Jockey with Apache License 2.0 5 votes vote down vote up
@Override
public void onAction2(View button) {
    if (!MediaStoreUtil.hasPermission(mContext)) {
        Intent intent = new Intent();
        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null);
        intent.setData(uri);
        mContext.startActivity(intent);
    }
}
 
Example 5
Source File: Permissions.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
private static Intent getApplicationSettingsIntent(@NonNull Context context) {
  Intent intent = new Intent();
  intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
  Uri uri = Uri.fromParts("package", context.getPackageName(), null);
  intent.setData(uri);

  return intent;
}
 
Example 6
Source File: Installer.java    From fdroidclient with GNU General Public License v3.0 5 votes vote down vote up
private static void sendBroadcastUninstall(Context context, Apk apk, String action,
                                           PendingIntent pendingIntent, String errorMessage) {
    Uri uri = Uri.fromParts("package", apk.packageName, null);

    Intent intent = new Intent(action);
    intent.setData(uri); // for broadcast filtering
    intent.putExtra(Installer.EXTRA_APK, apk);
    intent.putExtra(Installer.EXTRA_USER_INTERACTION_PI, pendingIntent);
    if (!TextUtils.isEmpty(errorMessage)) {
        intent.putExtra(Installer.EXTRA_ERROR_MESSAGE, errorMessage);
    }
    LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}
 
Example 7
Source File: CustomersFragment.java    From Woodmin with Apache License 2.0 5 votes vote down vote up
@Override
public void sendEmail(Customer customer) {
    if(customer.getEmail() != null){
        Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",customer.getEmail(), null));
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "");
        startActivity(Intent.createChooser(emailIntent, "Woodmin"));
    }
}
 
Example 8
Source File: UIStatusView.java    From FastAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View view) {
    switch (currentStatus) {
        case 0://加载中

            break;
        case 1://加载成功有数据

            break;
        case -1://加载成功无数据

            break;
        case -2://数据异常

            break;
        case -3://网络异常

            break;
        case -4://服务器异常

            break;
        case -5://没有登录

            break;
        case -6://没有查看/执行权限

            break;
        case -7://没有运行权限
            Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            Uri uri = Uri.fromParts("package", context.getPackageName(), null);
            intent.setData(uri);
            context.startActivity(intent);
            break;
        default:
            break;
    }
}
 
Example 9
Source File: SystemPermissionHelper.java    From q-municate-android with Apache License 2.0 5 votes vote down vote up
public static void openSystemSettings(Context context) {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY);
    Uri uri = Uri.fromParts("package", context.getPackageName(), null);
    intent.setData(uri);
    context.startActivity(intent);
}
 
Example 10
Source File: ProductsActivity.java    From android-paypal-example with Apache License 2.0 5 votes vote down vote up
private void contactUs(){
    Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
            "mailto","[email protected]", null));
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
    emailIntent.putExtra(Intent.EXTRA_TEXT, "Body");
    startActivity(Intent.createChooser(emailIntent, "Send email..."));
}
 
Example 11
Source File: PromptForPermissionsActivity.java    From medic-gateway with GNU Affero General Public License v3.0 5 votes vote down vote up
public void btnOk_onClick(View v) {
	if(isDemand) {
		// open app manager for this app
		Intent i = new Intent(ACTION_APPLICATION_DETAILS_SETTINGS,
				Uri.fromParts("package", getPackageName(), null));
		i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		startActivity(i);

		finish();
	} else makePermissionRequest();
}
 
Example 12
Source File: OpenAppSettingsModule.java    From react-native-app-settings with Apache License 2.0 5 votes vote down vote up
@ReactMethod
public void open() {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts("package", reactContext.getPackageName(), null);
    intent.setData(uri);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    reactContext.startActivity(intent);
}
 
Example 13
Source File: Permissions.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
private static Intent getApplicationSettingsIntent(@NonNull Context context) {
  Intent intent = new Intent();
  intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
  Uri uri = Uri.fromParts("package", context.getPackageName(), null);
  intent.setData(uri);

  return intent;
}
 
Example 14
Source File: Permissions.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private static Intent getApplicationSettingsIntent(@NonNull Context context) {
  Intent intent = new Intent();
  intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
  Uri uri = Uri.fromParts("package", context.getPackageName(), null);
  intent.setData(uri);

  return intent;
}
 
Example 15
Source File: DevicePluginInfoFragment.java    From DeviceConnect-Android with MIT License 4 votes vote down vote up
/**
 * Open uninstall dialog.
 */
private void openUninstall() {
    Uri uri = Uri.fromParts("package", mPluginInfo.getPackageName(), null);
    Intent intent = new Intent(Intent.ACTION_DELETE, uri);
    startActivityForResult(intent, REQUEST_CODE);
}
 
Example 16
Source File: ImagePicker.java    From androidnative.pri with Apache License 2.0 4 votes vote down vote up
static private void importImageFromContentUri(Uri uri) {
    Activity activity = org.qtproject.qt5.android.QtNative.activity();

    String[] columns = { MediaStore.Images.Media.DATA, MediaStore.Images.ImageColumns.ORIENTATION };

    Cursor cursor = activity.getContentResolver().query(uri, columns, null, null, null);
    if (cursor == null) {
        Log.d(TAG,"importImageFromContentUri: Query failed");
        return;
    }

    cursor.moveToFirst();
    ArrayList<Uri> uris = new ArrayList(cursor.getCount());

    for (int i = 0 ; i < cursor.getCount(); i++) {
        int columnIndex;
        columnIndex = cursor.getColumnIndex(columns[0]);
        String path = cursor.getString(columnIndex);

        /*
        columnIndex = cursor.getColumnIndex(columns[1]);
        int orientation = cursor.getInt(columnIndex);
        */

        if (path == null) {
            Log.d(TAG,"importImageFromContentUri: The path of image is null. The image may not on the storage.");
            continue;
        }

        Uri fileUri = Uri.fromParts("file",path,"");
        uris.add(fileUri);

        Log.d(TAG,"importImageFromContentUri: " + fileUri.toString());
    }

    importImageFromFileUri(uris);
    cursor.close();



}
 
Example 17
Source File: RLAppUtil.java    From Roid-Library with Apache License 2.0 4 votes vote down vote up
/**
 * @param context
 * @param packageName
 */
public static void uninstall(Context context, String packageName) {
    Uri uri = Uri.fromParts("package", packageName, null);
    Intent it = new Intent(Intent.ACTION_DELETE, uri);
    context.startActivity(it);
}
 
Example 18
Source File: AboutFragment.java    From FlipGank with Apache License 2.0 4 votes vote down vote up
@OnClick(R.id.click_email)
protected void email() {
    Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto","[email protected]", null));
    startActivity(Intent.createChooser(intent, "Send Email to [email protected]"));
}
 
Example 19
Source File: PackageInstallerUtils.java    From TvAppRepo with Apache License 2.0 4 votes vote down vote up
public static void uninstallApp(Activity activity, @NonNull String packageName) {
    Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package",
            activity.getPackageManager().getPackageArchiveInfo(packageName, 0).packageName,
            null));
    activity.startActivity(intent);
}
 
Example 20
Source File: MainActivity.java    From Simple-Accounting with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	// Handle action bar item clicks here. The action bar will
	// automatically handle clicks on the Home/Up button, so long
	// as you specify a parent activity in AndroidManifest.xml.
	int id = item.getItemId();

	switch (id) {
		case R.id.action_graph:
			Intent i = new Intent(getApplicationContext(), GraphActivity.class);
			i.putExtra(GraphActivity.GRAPH_SESSION, new Session(editableMonth, editableYear, editableCurrency));
			i.putExtra(GraphActivity.GRAPH_UPDATE_MONTH, updateMonth);
			i.putExtra(GraphActivity.GRAPH_UPDATE_YEAR, updateYear);
			startActivity(i);
			return true;
		case R.id.action_show_months:
			startActivity(new Intent(this, MonthActivity.class));
			return true;
		case R.id.action_print:
			if (table.getChildCount() > 1) {
				if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
					PrintManager printM = (PrintManager) getSystemService((Context.PRINT_SERVICE));

					String job = getString(R.string.app_name) + ": " +
							(!isSelectedMonthOlderThanUpdate()?
									getString(MONTH_STRINGS[editableMonth]):getString(MONTH_STRINGS[updateMonth]));
					printM.print(job,
							new PPrintDocumentAdapter(this, table, new Session(editableMonth, editableYear,
									currencyName), new int[]{updateMonth, updateYear}),
							null);
				}
			} else {
				Snackbar.make(table, getString(R.string.nothing_to_print), Snackbar.LENGTH_SHORT).show();
			}

			return true;
		case R.id.action_donate:
			startActivity(new Intent(getApplicationContext(), DonateActivity.class));
			return true;
		case R.id.action_settings:
			startActivity(new Intent(this, SettingsActivity.class));
			return true;
		case R.id.action_feedback:
			Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
					Uri.fromParts("mailto", getString(R.string.email), null));
			emailIntent.putExtra(Intent.EXTRA_SUBJECT,
					getString(R.string.feedback_about, getString(R.string.app_name)));
			emailIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.mail_content));
			emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{getString(R.string.email)});//makes it work in 4.3
			Intent chooser = Intent.createChooser(emailIntent, getString(R.string.choose_email));
			chooser.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(chooser);//prevents exception
			startActivity(chooser);
			return true;
	}

	return super.onOptionsItemSelected(item);
}