Example usage for android.content Intent setAction

List of usage examples for android.content Intent setAction

Introduction

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

Prototype

public @NonNull Intent setAction(@Nullable String action) 

Source Link

Document

Set the general action to be performed.

Usage

From source file:Main.java

public static List<ResolveInfo> getBrowsers(Context context) {
    PackageManager pm = context.getPackageManager();

    Intent query = new Intent();
    query.setAction(Intent.ACTION_VIEW);
    query.setData(Uri.parse("http://localhost"));

    return pm.queryIntentActivities(query, 0);
}

From source file:Main.java

public static boolean isHaveMarket(Context getContext) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.MAIN");
    intent.addCategory("android.intent.category.APP_MARKET");
    PackageManager pm = getContext.getPackageManager();
    List<ResolveInfo> infos = pm.queryIntentActivities(intent, 0);
    return infos.size() > 0;
}

From source file:Main.java

public static void sendBroadcast(Context context, String action, String extra, int value) {
    Intent broadcast = new Intent();
    broadcast.setAction(action);
    broadcast.putExtra(extra, value);//from w  w w.j a  va2 s  . co m
    context.sendBroadcast(broadcast);
}

From source file:Main.java

public static void jumpToSystemShareImages(Context context, ArrayList<Uri> imageUris) {
    Intent shareIntent = new Intent();
    shareIntent.setAction("android.intent.action.SEND_MULTIPLE");
    shareIntent.putParcelableArrayListExtra("android.intent.extra.STREAM", imageUris);
    shareIntent.setType("image/*");
    context.startActivity(shareIntent);/*  w  w  w. j a  v  a  2  s  . co m*/
}

From source file:Main.java

public static Intent buildIntentWithAction(Context context, Class clazz, String action) {
    Intent intent = new Intent(context, clazz);
    intent.setAction(action);
    return intent;
}

From source file:Main.java

public static void sharePic(Uri uri, String desc, Context context) {

    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    shareIntent.setType("image/jpeg");
    context.startActivity(Intent.createChooser(shareIntent, desc));
}

From source file:Main.java

public static void startInstall(final Context context, String fileName) {
    Intent intent = new Intent();
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.parse("file://" + getSdcardFileName(fileName)),
            "application/vnd.android.package-archive");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/* w  w  w .  j  a va  2 s  .  c  o  m*/
}

From source file:Main.java

public static void editMessage(Context context, String msg) {
    Intent msgIntent = new Intent();
    msgIntent.setAction(Intent.ACTION_SENDTO);
    msgIntent.putExtra("sms_body", msg);
    context.startActivity(msgIntent);/*from  www.j a va  2 s .  com*/
}

From source file:Main.java

public static void installApk(Context context, File file) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.setType("application/vnd.android.package-archive");
    intent.setData(Uri.fromFile(file));//from   w  ww . j  ava  2s. c  o  m
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);

}

From source file:Main.java

public static void showPicture(Context mContext, String imagePath) {
    File file = new File(imagePath);
    if (file != null && file.isFile() == true) {
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(file), "image/*");
        mContext.startActivity(intent);//from   w ww . j  av  a2s.  c  o  m
    }
}