Example usage for android.content Intent Intent

List of usage examples for android.content Intent Intent

Introduction

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

Prototype

public Intent(Context packageContext, Class<?> cls) 

Source Link

Document

Create an intent for a specific component.

Usage

From source file:Main.java

public static void choosePictureFromExternal(Activity activity, int requestCode) {
    Intent choosePictureIntent = new Intent(Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    activity.startActivityForResult(choosePictureIntent, requestCode);
}

From source file:Main.java

public static void startActivityClearTask(Activity activity, Class<? extends Activity> clazz) {
    Intent intent = new Intent(activity, clazz);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_CLEAR_TASK
            | Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(intent);/*ww  w  . ja v  a 2  s  . c o  m*/
    activity.overridePendingTransition(0, 0);
}

From source file:Main.java

public static void callPhone(Activity activity, String phoneNumber) {
    Intent phoneIntent = new Intent("android.intent.action.CALL", Uri.parse("tel:" + phoneNumber));
    activity.startActivity(phoneIntent);
}

From source file:Main.java

public static Intent createShortcutIntent(String url) {
    Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    long urlHash = url.hashCode();
    long uniqueId = (urlHash << 32) | shortcutIntent.hashCode();
    shortcutIntent.putExtra(Browser.EXTRA_APPLICATION_ID, Long.toString(uniqueId));
    return shortcutIntent;
}

From source file:Main.java

public static void dialog(Context context, String inputStr) {
    Intent phoneIntent = new Intent("android.intent.action.CALL", Uri.parse("tel:" + inputStr));

    context.startActivity(phoneIntent);//w w  w.  ja va  2  s .c om

}

From source file:Main.java

public static void finish(Context packageContext, Class<?> cls) {
    Intent intent = new Intent(packageContext, cls);
    packageContext.startActivity(intent);
    ((Activity) packageContext).finish();
}

From source file:Main.java

public static void startService(Context c, Class<? extends Service> cls) {
    c.startService(new Intent(c, cls));
}

From source file:Main.java

public static void startActivity(Context from, Class<?> to, Bundle data) {
    Intent i = new Intent(from, to);
    i.putExtras(data);//  w  w w.j av  a 2s  . c  o m
    from.startActivity(i);
}

From source file:Main.java

public static boolean stopService(Context context, String className) {
    try {//from w  w w .  j av a 2s.com
        Intent intent = new Intent(context, Class.forName(className));
        return context.stopService(intent);
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}

From source file:Main.java

public static void callPhone(Context context, String phoneNumber) {
    context.startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber)));
}