Example usage for android.content ActivityNotFoundException printStackTrace

List of usage examples for android.content ActivityNotFoundException printStackTrace

Introduction

In this page you can find the example usage for android.content ActivityNotFoundException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:Main.java

public static void scoreApp(Activity activity) {
    Uri uri = Uri.parse("market://details?id=" + activity.getPackageName());
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    try {/*  w w  w  .j  a  va2  s .c  o  m*/
        activity.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static boolean launchActivity(Context from, Intent intent) {
    if (from == null)
        throw new NullPointerException("from == null");
    try {/*from w ww .  j  av a2  s .  c o  m*/
        from.startActivity(intent);
        return true;
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
        return false;
    }
}

From source file:Main.java

public static void startActivity(Activity context, Class clazz, Bundle bundle) {
    if (context != null) {
        try {/* w ww  .  ja  v a2  s  . co  m*/
            Intent intent = new Intent(context, clazz);
            intent.putExtra("bundle", bundle);
            context.startActivity(intent);

        } catch (ActivityNotFoundException e) {
            e.printStackTrace();

        }

    }
}

From source file:cn.tofly.mis.waterusermanager.common.tools.ActivityUtils.java

/**
 * ?Activity//  w ww  .  j  ava  2  s. c o m
 *
 * @param context
 * @param clazz
 * @param bundle
 */
public static void startActivity(Activity context, Class clazz, Bundle bundle) {
    if (context != null) {
        try {
            Intent intent = new Intent(context, clazz);
            intent.putExtra("bundle", bundle);
            context.startActivity(intent);

        } catch (ActivityNotFoundException e) {
            e.printStackTrace();

        }

    }
}

From source file:Main.java

public static void callGoogleTranslateApps(Context context, String word, String toLang) {
    try {/*  ww w .  j av a 2s.  co m*/
        Intent i = new Intent();

        i.setAction(Intent.ACTION_VIEW);

        i.putExtra("key_text_input", word);
        i.putExtra("key_text_output", "");
        i.putExtra("key_language_from", "en");
        i.putExtra("key_language_to", "vi");
        i.putExtra("key_suggest_translation", "");
        i.putExtra("key_from_floating_window", false);

        i.setComponent(new ComponentName("com.google.android.apps.translate",
                "com.google.android.apps.translate.TranslateActivity"));
        context.startActivity(i);
    } catch (ActivityNotFoundException ex) {
        Toast.makeText(context, "Google translate app is not installed", Toast.LENGTH_SHORT).show();
        ex.printStackTrace();
    }
}

From source file:com.idlab.idcorp.assignment_android.common.utils.PermissionUtil.java

public static void showRationalDialog(final Context context, String message) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(context.getString(R.string.permission_dialog_title)).setMessage(message).setPositiveButton(
            context.getString(R.string.permission_dialog_setting), new DialogInterface.OnClickListener() {
                @Override//from w  w w  . j a v a2s  .c o m
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
                                .setData(Uri.parse("package:" + context.getPackageName()));
                        context.startActivity(intent);
                    } catch (ActivityNotFoundException e) {
                        e.printStackTrace();
                        Intent intent = new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
                        context.startActivity(intent);
                    }
                }
            }).setNegativeButton(context.getString(R.string.permission_dialog_close), null);
    builder.show();
}

From source file:org.sensapp.android.sensappdroid.api.SensAppHelper.java

public static Dialog getInstallationDialog(final Context context) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage("SensApp application is needed. Would you like install it now?");
    builder.setCancelable(false);/*www.jav  a 2 s.c  o  m*/
    builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            Uri uri = Uri.parse("market://details?id=" + "org.sensapp.android.sensappdroid");
            try {
                context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
            } catch (ActivityNotFoundException e) {
                e.printStackTrace();
            }
        }
    });
    builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    return builder.create();
}

From source file:util.mediamanager.PlaylistUtils.java

public static void ListMediaButtonReceivers(Context context, String query) {

    try {// w  w  w  .  j av a  2s  . c  o m

        final Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
        PackageManager packageManager = context.getPackageManager();

        List<ResolveInfo> mediaReceivers = packageManager.queryBroadcastReceivers(mediaButtonIntent,
                PackageManager.GET_INTENT_FILTERS | PackageManager.GET_RESOLVED_FILTER);

        for (int i = mediaReceivers.size() - 1; i >= 0; i--) {
            ResolveInfo mediaReceiverResolveInfo = mediaReceivers.get(i);
            String name = mediaReceiverResolveInfo.activityInfo.applicationInfo.sourceDir + ", "
                    + mediaReceiverResolveInfo.activityInfo.name;
            String cn = mediaReceiverResolveInfo.resolvePackageName;
            String cn1 = mediaReceiverResolveInfo.activityInfo.toString();
            Log.d(Constants.APP.TAG, "resolvePackageName media receivers = " + cn);
            Log.d(Constants.APP.TAG, "activityInfo = " + cn1);
        }

        mediaButtonIntent.setAction(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
        //mediaButtonIntent.setComponent(new ComponentName("com.spotify.music", "com.spotify.music.MainActivity"));
        mediaButtonIntent.putExtra(SearchManager.QUERY, "GM1");
        mediaButtonIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(mediaButtonIntent);
    } catch (ActivityNotFoundException e) {
        Log.e(Constants.APP.TAG, "Error searching Spotify w/ query '" + query + "'");
        //Toast.makeText(mRideManager.mAppContext, String.format("Error parsing query \"%s\"", query), Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }
}

From source file:com.frostwire.android.gui.util.UIUtils.java

public static void openURL(Context context, String url) {
    try {//from   w  ww.jav  a 2  s  .  c om
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        context.startActivity(i);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
        // ignore
        // yes, it happens
    }
}

From source file:com.grarak.kerneladiutor.utils.Utils.java

public static void launchUrl(String url, Context context) {
    try {/* w  w w .j ava 2  s .c om*/
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        context.startActivity(i);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    }
}