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 installApk(Context context, Uri file) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(file, "application/vnd.android.package-archive");
    context.startActivity(intent);/*from w w  w.j av a2 s.co  m*/
}

From source file:Main.java

public static void putData(Context context, Class<?> activity, String key, String value) {
    Intent intent = new Intent();
    intent.setClass(context, activity);//from  w w  w  .  j  a va 2s. c  om
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.putExtra(key, value);
    context.startActivity(intent);
}

From source file:Main.java

public static void animTo(Activity activity, Class<?> toClass, int enterAnim, int exitAnim) {
    Intent intent = new Intent();
    intent.setClass(activity, toClass);/*from   www.  j a v a  2  s  .com*/
    activity.startActivity(intent);
    activity.overridePendingTransition(enterAnim, exitAnim);
}

From source file:Main.java

public static void showWebPage(Context context, String url) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    Uri uri = Uri.parse(url);//from  www . j a va 2  s .c o  m
    intent.setData(uri);
    context.startActivity(intent);
}

From source file:Main.java

public static final void viewImageFromUri(Context ctx, Uri u) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(u, "image/*");
    ctx.startActivity(intent);//  ww w.  j  ava  2s.c om
}

From source file:Main.java

public static void startActivityForResult(Activity context, Class<?> cls, int requestCode) {
    Intent intent = new Intent();
    intent.setClass(context, cls);//  w  ww. jav  a 2s. co  m
    context.startActivityForResult(intent, requestCode);
}

From source file:Main.java

private static void sendBroadcastFile(Context context, String filepath, double progress) {
    Intent intent = new Intent();
    intent.setAction("file_receiver");
    intent.putExtra("path", filepath);
    intent.putExtra("progress", progress);
    context.sendBroadcast(intent);/*from  ww w .ja v a 2 s  . co  m*/
}

From source file:Main.java

public static void openYYB2(Context context) {

    Intent intent2 = new Intent();
    intent2.setComponent(new ComponentName("com.tencent.android.qqdownloader",
            "com.connector.tencent.connector.ConnectionActivity"));
    intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent2);/*w w  w.jav a  2 s  . c o  m*/

}

From source file:Main.java

public static void pauseMusic(Context context) {
    Intent freshIntent = new Intent();
    freshIntent.setAction("com.android.music.musicservicecommand.pause");
    freshIntent.putExtra("command", "pause");
    context.sendBroadcast(freshIntent);/*from  w ww . j a v  a2s . c  o  m*/
}

From source file:Main.java

public static void shareViaIntent(Context context, String subject, String extraText) {
    Intent sendIntent = new Intent();
    sendIntent.setType("text/plain");
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    sendIntent.putExtra(Intent.EXTRA_TEXT, extraText);
    context.startActivity(sendIntent);//from  w w w. ja  va 2s  .c om
}