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 sendSMS(String smsBody, Context context, String num)

{

    Uri smsToUri = Uri.parse("smsto:" + num);

    Intent intent = new Intent(Intent.ACTION_SENDTO, smsToUri);

    intent.putExtra("sms_body", smsBody);

    context.startActivity(intent);

}

From source file:Main.java

public static void sendSMS(Context context, String number, String message) {
    Uri uri = Uri.parse("smsto:" + number);

    Intent sendIntent = new Intent(Intent.ACTION_VIEW, uri);
    sendIntent.putExtra("sms_body", message);

    context.startActivity(sendIntent);
}

From source file:Main.java

public static void launchApp(Context context, String packageName) {
    PackageManager pm = context.getPackageManager();
    Intent intent = pm.getLaunchIntentForPackage(packageName);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:Main.java

public static void intentDirection(Context context, double latitude, double longitude) {
    Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
            Uri.parse("http://maps.google.com/maps?daddr=" + latitude + "," + longitude));
    context.startActivity(intent);
}

From source file:Main.java

public static void launchApplication(Context context, String pkgname) {
    Intent intent = context.getPackageManager().getLaunchIntentForPackage(pkgname);
    intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);

    context.startActivity(intent);
}

From source file:com.app.common.util.IntentUtils.java

public static void startWebActivity(Context context, String url) {
    final Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));//from w  w w .  j ava  2s.  c o  m
    context.startActivity(intent);
}

From source file:Main.java

public static void startDialer(Context context, String phoneNumber) {
    try {/*from   www  .  jav  a 2  s.c  om*/
        Intent dial = new Intent();
        dial.setAction(Intent.ACTION_DIAL);
        dial.setData(Uri.parse("tel:" + phoneNumber));
        context.startActivity(dial);
    } catch (Exception ex) {
        Log.e(TAG, "Error starting phone dialer intent.", ex);
        Toast.makeText(context, "Sorry, we couldn't find any app to place a phone call!", Toast.LENGTH_SHORT)
                .show();
    }
}

From source file:Main.java

public static void sendIntent(Context context, Class classes, String key, Parcelable value) {
    Intent intent = new Intent();
    intent.setClass(context, classes);//from w  w w.j a  v a2  s  .com
    intent.putExtra(key, value);
    context.startActivity(intent);
}

From source file:Main.java

public static void launchActivity(Context context, Class<?> activity, Bundle bundle) {
    Intent intent = new Intent(context, activity);
    intent.putExtras(bundle);// w  w  w.j  ava  2  s.  co m
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    context.startActivity(intent);
}

From source file:Main.java

public static void redirectActivity(Context fromClass, Class<?> toClass, Bundle bundle) {
    Intent intent = new Intent();
    intent.setClass(fromClass, toClass);
    if (null != bundle) {
        intent.putExtras(bundle);//  w  ww .ja  v a2  s .  c  o m
    }
    fromClass.startActivity(intent);

}