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() 

Source Link

Document

Create an empty intent.

Usage

From source file:Main.java

public static void InvokeActivity(Activity activity, Class class1) {
    Intent intent = new Intent();
    intent.setClass(activity, class1);
    intent.addCategory("android.intent.category.DEFAULT");
    activity.startActivity(intent);//from   w  w w .j  a v  a 2  s.  c  o m
}

From source file:Main.java

public static void sendMail(Context context, String email) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { email });
    sendIntent.putExtra(Intent.EXTRA_TEXT, "");
    sendIntent.setType("text/plain");
    context.startActivity(sendIntent);//from w ww  .  j a  v  a2 s.com
}

From source file:Main.java

public static void broadcastAction(Context context, String action) {
    Intent intent = new Intent();
    intent.setAction(action);//from   w  ww .  ja v a  2  s .  c om
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void startActivity(Activity activity, Class<?> cls) {
    Intent intent = new Intent();
    intent.setClass(activity, cls);/*from   w  w w . ja v  a 2  s  . c  o m*/
    activity.startActivity(intent);

}

From source file:Main.java

public static Intent getAllIntent(String param) {

    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(Intent.ACTION_VIEW);
    Uri uri = Uri.fromFile(new File(param));
    intent.setDataAndType(uri, "*/*");
    return intent;
}

From source file:Main.java

private static Intent createCalendarIntent(String action) {
    Intent intent = new Intent();
    intent.setAction(action);/*  ww w  .j  a  v a2s  .  c  o m*/
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
            | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    return intent;
}

From source file:Main.java

public static void shareApkInfo(String info, Context context) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.SEND");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, info);
    context.startActivity(intent);/*w ww.  j  a va2 s.c  o m*/
}

From source file:Main.java

private static Intent getApkFileIntent(File file) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    return intent;
}

From source file:Main.java

public static void turnToActivity(Context context, Class activityClass) {
    Intent intent = new Intent();
    intent.setClass(context, activityClass);
    context.startActivity(intent);/*from  ww  w  . java2s  .  c om*/
}

From source file:Main.java

public static Intent getInstallIntent(File file) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    return intent;
}