Example usage for android.content Context startActivity

List of usage examples for android.content Context startActivity

Introduction

In this page you can find the example usage for android.content Context startActivity.

Prototype

public abstract void startActivity(@RequiresPermission Intent intent);

Source Link

Document

Same as #startActivity(Intent,Bundle) with no options specified.

Usage

From source file:Main.java

public static void startActivitySafe(Context context, Intent intent) {
    try {/*from   w ww . j a  va2s  . c  o  m*/
        context.startActivity(intent);
    } catch (Exception e) {
        // ignore
        e.printStackTrace();
    }
}

From source file:Main.java

public static boolean startDial(Context context, String number) {
    try {/*from   w w w  .j a  v  a 2s.  c o  m*/
        context.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + number)));
    } catch (Exception e) {
        return false;
    }

    return true;
}

From source file:Main.java

private static void startViewUri(Context context, String uri) {
    context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri)));
}

From source file:Main.java

public static void call(Context context, String s) {
    try {/*from  ww  w  .  j  a v  a2s .  c o m*/
        context.startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + s)));
    } catch (Exception e) {
        context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("tel:" + s)));
    }
}

From source file:Main.java

public static void newMessageNetwork(Context context) {
    Intent intent = new Intent(context, null);
    context.startActivity(intent);
}

From source file:Main.java

/**
 * Launch this app store site./*www  .  jav  a 2 s .  co  m*/
 *
 * @param context Context
 */
public static void launchStore(Context context) {
    try {
        context.startActivity(
                new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())));
    } catch (ActivityNotFoundException e) {
        Log.w(TAG, "Occurred ActivityNotFoundException.", e);
    }
}

From source file:Main.java

/**
 * Safely wrapper of {@link Context#startActivity(Intent)}.
 * //from   w w w.  j  ava2s . com
 * @param context
 * @param intent
 * 
 * @return True means start success, otherwise false.
 */
public final static boolean startActivitySafely(Context context, Intent intent) {
    try {
        context.startActivity(intent);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}

From source file:Main.java

public static void startActionCall(String phoneNumber, Context cxt) {
    Uri phoneNum = Uri.parse("tel:" + phoneNumber);
    cxt.startActivity(new Intent(Intent.ACTION_CALL, phoneNum));
}

From source file:Main.java

public static void restartActivity(Context context, Intent intent) {
    ((Activity) context).finish();
    context.startActivity(intent);
}

From source file:Main.java

public static boolean openUrlSchema(Context paramContext, String paramString) {
    try {/*from  w ww . ja  v a 2 s  .c  o  m*/
        paramContext.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(paramString)));
        return true;
    } catch (Exception localException) {
        localException.printStackTrace();
    }
    return false;
}