Example usage for android.net Uri fromParts

List of usage examples for android.net Uri fromParts

Introduction

In this page you can find the example usage for android.net Uri fromParts.

Prototype

public static Uri fromParts(String scheme, String ssp, String fragment) 

Source Link

Document

Creates an opaque Uri from the given components.

Usage

From source file:Main.java

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);//w w w .  j a  va2 s. c  om
}

From source file:Main.java

public static void installRemoteAPK(Context context, String packageName) {
    Uri installUri = Uri.fromParts("package", packageName, null);
    Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
    context.startActivity(intent);/*from  w ww.  j  a  v a2s  .  c o  m*/
}

From source file:Main.java

/**
 * Launch Application Setting to grant permission.
 *//*  w w  w. j  av a  2  s.c  om*/
public static void launchPermissionSettings(Activity activity) {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setData(Uri.fromParts("package", activity.getPackageName(), null));
    activity.startActivity(intent);
}

From source file:Main.java

public static void sendFeedback2(Context context) {

    String versionName = "";

    try {//from  ww  w .  j a  v a  2 s  . c  o  m

        versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;

    } catch (NameNotFoundException e) {

        e.printStackTrace();
    }

    StringBuffer sb = new StringBuffer();
    sb.append("We would like to hear your feedback and improvement ideas. Please feel free to share below :")
            .append("\r\n").append("\r\n").append("\r\n").append("Attach Screenshots (if any) : ")
            .append("\r\n").append("\r\n").append("\r\n").append("Running on ").append(android.os.Build.MODEL)
            .append("\r\n").append("OS Version : ").append(android.os.Build.VERSION.RELEASE).append("\r\n")
            .append("Client Version : ").append(versionName);

    Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
            Uri.fromParts("mailto", "messageplus_feedback@starhub.com", null));
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Message+ - Feedback");
    emailIntent.putExtra(Intent.EXTRA_TEXT, sb.toString());
    context.startActivity(Intent.createChooser(emailIntent, "Choose email client"));

}

From source file:Main.java

@SuppressLint("InlinedApi")
public static void openSys(Context context, String packageName) {
    Intent intent = new Intent();
    final int apiLevel = Build.VERSION.SDK_INT;
    if (apiLevel >= 9) {
        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        intent.setData(Uri.fromParts("package", packageName, null));
    } else {//from   w w w  .  j a  v  a  2  s .c o m
        intent.setAction(Intent.ACTION_VIEW);
        intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
        String appPkgName = (apiLevel == 8 ? "pkg" : "com.android.settings.ApplicationPkgName");
        intent.putExtra(appPkgName, packageName);
    }
    context.startActivity(intent);
}

From source file:Main.java

public static Intent getApplicationDetailsIntent(String packageName) {

    Intent intent = new Intent();
    final int apiLevel = Build.VERSION.SDK_INT;

    if (apiLevel >= 9) { // above 2.3
        intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
        Uri uri = Uri.fromParts(SCHEME, packageName, null);
        intent.setData(uri);//w  w w. j  a  v  a2s.  c om
    } else { // below 2.3
        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);
    }
    return intent;
}

From source file:com.github.akinaru.rfdroid.menu.MenuUtils.java

/**
 * Execute actions according to selected menu item
 *
 * @param menuItem MenuItem object/*  w ww .j ava2  s . co m*/
 * @param mDrawer  navigation drawer
 * @param context  android context
 */
public static void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context) {

    switch (menuItem.getItemId()) {
    case R.id.switch_chart_data: {
        break;
    }
    case R.id.report_bugs: {
        Intent intent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", "kiruazoldik92@gmail.com", null));
        intent.putExtra(Intent.EXTRA_SUBJECT, "RFdroid Issue");
        intent.putExtra(Intent.EXTRA_TEXT, "Your error report here...");
        context.startActivity(Intent.createChooser(intent, "Report a problem"));
        break;
    }
    case R.id.open_source_components: {
        OpenSourceItemsDialog d = new OpenSourceItemsDialog(context);
        d.show();
        break;
    }
    case R.id.about_app: {
        AboutDialog dialog = new AboutDialog(context);
        dialog.show();
        break;
    }
    }
    mDrawer.closeDrawers();
}

From source file:org.wdd.app.android.catgirl.permission.SettingExecutor.java

@Override
public void execute() {
    Context context = PermissionUtils.getContext(object);
    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts("package", context.getPackageName(), null);
    intent.setData(uri);/*from  w  ww  .j a v a 2 s . co m*/
    startAppSettings(object, intent);
}

From source file:com.miandui.utils.runtimePermission.SettingExecutor.java

@Override
public void execute() {
    Context context = PermissionUtils.getContext(object);
    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts("package", context.getPackageName(), null);
    intent.setData(uri);/*from   www .  ja  v a 2  s .c om*/
    startForResult(object, intent, requestCode);
}

From source file:com.github.akinaru.bleanalyzer.menu.MenuUtils.java

/**
 * Execute actions according to selected menu item
 *
 * @param menuItem MenuItem object/*  w w  w  . java 2 s.  c  o m*/
 * @param mDrawer  navigation drawer
 * @param context  android context
 */
public static void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context,
        IBtActivity activity) {

    switch (menuItem.getItemId()) {
    case R.id.switch_chart_data: {
        break;
    }
    case R.id.rfdroid: {
        Intent i = new Intent(context, RFdroidActivity.class);
        context.startActivity(i);
        break;
    }
    case R.id.scan_btn_nv: {
        if (activity != null)
            activity.toggleScan();
        break;
    }
    case R.id.report_bugs: {
        Intent intent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", context.getResources().getString(R.string.email_addr), null));
        intent.putExtra(Intent.EXTRA_SUBJECT, context.getResources().getString(R.string.issue_subject));
        intent.putExtra(Intent.EXTRA_TEXT, context.getResources().getString(R.string.report_hint));
        context.startActivity(
                Intent.createChooser(intent, context.getResources().getString(R.string.issue_title)));
        break;
    }
    case R.id.open_source_components: {
        OpenSourceItemsDialog d = new OpenSourceItemsDialog(context);
        d.show();
        break;
    }
    case R.id.about_app: {
        AboutDialog dialog = new AboutDialog(context);
        dialog.show();
        break;
    }
    }
    mDrawer.closeDrawers();
}