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:ru.dublgis.androidhelpers.DesktopUtils.java

public static void showApplicationSettings(final Context ctx) {
    try {//from w w w .  j  a v  a 2  s .  c o  m
        final Intent intent = new Intent();

        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.setData(Uri.fromParts("package", ctx.getPackageName(), null));
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

        ctx.startActivity(intent);
    } catch (final Throwable throwable) {
        Log.e(TAG, "showApplicationSettings throwable: " + throwable);
    }
}

From source file:com.innoc.secureline.ui.UpgradeCallDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
        builder = new AlertDialog.Builder(
                new ContextThemeWrapper(getActivity(), R.style.RedPhone_Light_Dialog));
    } else {//from w ww .  ja v  a  2  s .c  o m
        builder = new AlertDialog.Builder(getActivity(), R.style.RedPhone_Light_Dialog);
    }

    builder.setIcon(R.drawable.red_call);

    final String upgradeString = getActivity().getResources()
            .getString(R.string.RedPhoneChooser_upgrade_to_redphone);
    SpannableStringBuilder titleBuilder = new SpannableStringBuilder(upgradeString);
    titleBuilder.setSpan(new AbsoluteSizeSpan(20, true), 0, upgradeString.length(),
            Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    builder.setTitle(titleBuilder);

    //builder.setMessage(R.string.RedPhoneChooser_this_contact_also_uses_redphone_would_you_like_to_upgrade_to_a_secure_call);

    builder.setPositiveButton(R.string.RedPhoneChooser_secure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(getActivity(), SecureLineService.class);
            intent.setAction(SecureLineService.ACTION_OUTGOING_CALL);
            intent.putExtra(Constants.REMOTE_NUMBER, number);
            getActivity().startService(intent);

            Intent activityIntent = new Intent();
            activityIntent.setClass(getActivity(), SecureLine.class);
            activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(activityIntent);

            getActivity().finish();
        }
    });

    builder.setNegativeButton(R.string.RedPhoneChooser_insecure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            CallChooserCache.getInstance().addInsecureChoice(number);

            Intent intent = new Intent("android.intent.action.CALL",
                    Uri.fromParts("tel", number + CallListener.IGNORE_SUFFIX, null));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            getActivity().finish();
        }
    });

    AlertDialog alert = builder.create();

    alert.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            ((AlertDialog) dialog).setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });

            ((AlertDialog) dialog).setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });
            Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);

            Button negativeButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE);
        }
    });

    return alert;
}

From source file:com.whatsappcamera.RunTimePermission.java

private void callSettingActivity() {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
    intent.setData(uri);//from  w  w  w  .  j  a  v a 2  s .  c om
    activity.startActivity(intent);

}

From source file:com.mindprotectionkit.freephone.ui.UpgradeCallDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
        builder = new AlertDialog.Builder(
                new ContextThemeWrapper(getActivity(), R.style.RedPhone_Light_Dialog));
    } else {/*from  w  ww . j  ava2 s  .  co m*/
        builder = new AlertDialog.Builder(getActivity(), R.style.RedPhone_Light_Dialog);
    }

    builder.setIcon(R.drawable.red_call);

    final String upgradeString = getActivity().getResources()
            .getString(R.string.RedPhoneChooser_upgrade_to_redphone);
    SpannableStringBuilder titleBuilder = new SpannableStringBuilder(upgradeString);
    titleBuilder.setSpan(new AbsoluteSizeSpan(20, true), 0, upgradeString.length(),
            Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    builder.setTitle(titleBuilder);

    //builder.setMessage(R.string.RedPhoneChooser_this_contact_also_uses_redphone_would_you_like_to_upgrade_to_a_secure_call);

    builder.setPositiveButton(R.string.RedPhoneChooser_secure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(getActivity(), RedPhoneService.class);
            intent.setAction(RedPhoneService.ACTION_OUTGOING_CALL);
            intent.putExtra(Constants.REMOTE_NUMBER, number);
            getActivity().startService(intent);

            Intent activityIntent = new Intent();
            activityIntent.setClass(getActivity(), RedPhone.class);
            activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(activityIntent);

            getActivity().finish();
        }
    });

    builder.setNegativeButton(R.string.RedPhoneChooser_insecure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            CallChooserCache.getInstance().addInsecureChoice(number);

            Intent intent = new Intent("android.intent.action.CALL",
                    Uri.fromParts("tel", number + CallListener.IGNORE_SUFFIX, null));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            getActivity().finish();
        }
    });

    AlertDialog alert = builder.create();

    alert.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            ((AlertDialog) dialog).setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });

            ((AlertDialog) dialog).setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });
            Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);

            Button negativeButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE);
        }
    });

    return alert;
}

From source file:com.mapdirectiondemo.util.RunTimePermission.java

private void callSettingActivity() {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
    intent.setData(uri);/*from   www  .  j  a v  a2s . c  o  m*/
    activity.startActivity(intent);
}

From source file:com.duy.pascal.ui.activities.SplashScreenActivity.java

private void gotoSystemSetting() {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts("package", getPackageName(), null);
    intent.setData(uri);// w  w  w . j a  v  a2  s .  c  o  m
    startActivity(intent);
}

From source file:com.securecomcode.voice.ui.UpgradeCallDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
        builder = new AlertDialog.Builder(
                new ContextThemeWrapper(getActivity(), R.style.RedPhone_Light_Dialog));
    } else {//from w  ww  .j  a v  a  2 s . co  m
        builder = new AlertDialog.Builder(getActivity(), R.style.RedPhone_Light_Dialog);
    }

    builder.setIcon(R.drawable.red_call);

    final String upgradeString = getActivity().getResources()
            .getString(R.string.RedPhoneChooser_upgrade_to_redphone);
    SpannableStringBuilder titleBuilder = new SpannableStringBuilder(upgradeString);
    titleBuilder.setSpan(new AbsoluteSizeSpan(20, true), 0, upgradeString.length(),
            Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    builder.setTitle(titleBuilder);

    builder.setMessage(
            R.string.RedPhoneChooser_this_contact_also_uses_redphone_would_you_like_to_upgrade_to_a_secure_call);

    builder.setPositiveButton(R.string.RedPhoneChooser_secure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(getActivity(), RedPhoneService.class);
            intent.setAction(RedPhoneService.ACTION_OUTGOING_CALL);
            intent.putExtra(Constants.REMOTE_NUMBER, number);
            getActivity().startService(intent);

            Intent activityIntent = new Intent();
            activityIntent.setClass(getActivity(), RedPhone.class);
            activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(activityIntent);

            getActivity().finish();
        }
    });

    builder.setNegativeButton(R.string.RedPhoneChooser_insecure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            CallChooserCache.getInstance().addInsecureChoice(number);

            Intent intent = new Intent("android.intent.action.CALL",
                    Uri.fromParts("tel", number + CallListener.IGNORE_SUFFIX, null));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            getActivity().finish();
        }
    });

    AlertDialog alert = builder.create();

    alert.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            ((AlertDialog) dialog).setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });

            ((AlertDialog) dialog).setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });
            Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);

            Button negativeButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE);
        }
    });

    return alert;
}

From source file:com.andremion.louvre.StoragePermissionActivity.java

/**
 * Show UI with rationale for requesting a storage permission.
 * <p>/*w  w w  .j a va 2 s  .c om*/
 * "You should do this only if you do not have the permission and the context in
 * which the permission is requested does not clearly communicate to the user
 * what would be the benefit from granting this permission."
 * </p>
 */
private void showExplanation() {
    Snackbar.make(getWindow().getDecorView(),
            getString(R.string.activity_gallery_permission_request_explanation), Snackbar.LENGTH_INDEFINITE)
            .setAction(R.string.activity_gallery_permission_request_settings, new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent();
                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                    Uri uri = Uri.fromParts("package", getPackageName(), null);
                    intent.setData(uri);
                    startActivityForResult(intent, REQUEST_APP_SETTINGS);
                }
            }).show();
}

From source file:com.rafamaya.imagesearch.DataLayerListenerService.java

@Override
public void onMessageReceived(MessageEvent messageEvent) {
    LOGD(TAG, "onMessageReceived: " + messageEvent);

    // Check to see if the message is to start an activity
    if (messageEvent.getPath().equals(START_ACTIVITY_PATH)) {

        Intent startIntent = new Intent(this, PhotoActivity.class).setAction(Intent.ACTION_MAIN)
                .setData(Uri.fromParts("NODEID", messageEvent.getSourceNodeId(), ""));
        PendingIntent startPendingIntent = PendingIntent.getActivity(this, 0, startIntent, 0);
        long[] pattern = { 0, 100, 1000 };

        Notification notify = new NotificationCompat.Builder(this).setAutoCancel(false)
                .setStyle(new NotificationCompat.BigTextStyle()
                        .bigText("View or Search images and sync navigation!"))
                .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher))
                .setVibrate(pattern)/*  w  w w  .  j ava2  s  . com*/
                //.addAction(android.R.drawable.ic_menu_gallery, "View", startPendingIntent)
                .setSmallIcon(R.drawable.ic_launcher).setContentIntent(startPendingIntent).build();

        notify.flags |= Notification.FLAG_AUTO_CANCEL;

        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
        notificationManager.notify(0, notify);
    }
}

From source file:com.giovanniterlingen.windesheim.view.DownloadsActivity.java

private void checkPermissions() {
    if (!new PermissionController().verifyStoragePermissions(this)) {
        if (view != null) {
            Snackbar snackbar = Snackbar.make(view, getResources().getString(R.string.no_permission),
                    Snackbar.LENGTH_LONG);
            snackbar.setAction(getResources().getString(R.string.fix), new View.OnClickListener() {
                @Override/*from  www. j a va 2 s.co m*/
                public void onClick(View view) {
                    Intent intent = new Intent();
                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                    Uri uri = Uri.fromParts("package", getPackageName(), null);
                    intent.setData(uri);
                    startActivity(intent);
                }
            });
            snackbar.show();
        }
        showEmptyTextview();
    }
}