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 void installApp(Context mContext, String path) {
    Intent i = new Intent();
    i.setAction(Intent.ACTION_VIEW);
    i.addCategory(Intent.CATEGORY_DEFAULT);
    i.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.android.package-archive");
    mContext.startActivity(i);/*from  w ww. ja  va2  s.  c o m*/
}

From source file:Main.java

public static void uninstall(Context context, String pkgname) {

    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_DELETE);
    intent.setData(Uri.parse("package:" + pkgname));
    context.startActivity(intent);//www . ja v  a  2s .c  om
}

From source file:Main.java

public static void launchWeb(Context activityContext, String url) {
    //Log.d(TAG, "launchWeb::"+url);
    Intent in = new Intent();
    in.setAction(Intent.ACTION_VIEW);
    in.addCategory(Intent.CATEGORY_BROWSABLE);
    in.setData(Uri.parse(url));//  w w  w  .jav  a 2 s.  c o  m
    activityContext.startActivity(in);
}

From source file:Main.java

private static Intent createCalendarIntent(String action) {
    Intent intent = new Intent();
    intent.setAction(action);
    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

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  .j  a v  a 2s. c o  m*/
}

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);/* w ww.jav a 2  s  .c om*/
}

From source file:Main.java

public static void callPhone(Context context, String number) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_DIAL);
    intent.setData(Uri.parse(String.format("tel:%s", number)));
    context.startActivity(intent);/*from   www .  ja v  a  2  s .c o  m*/
}

From source file:Main.java

public static void openBrowser(Context context, String url) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));/*from w w w  .  ja va2 s . co  m*/
    context.startActivity(intent);
}

From source file:Main.java

public static final void sendToDeleteSearchResultItemData(Context context, String time) {
    Intent intent = new Intent();
    intent.setAction(HOMELIST_DELETE);
    intent.putExtra(SEARCH_TIME, time);/*www  .  j a v a2  s  .  co  m*/
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void showAppInfo(String packageName, Context context) {
    Intent intent = new Intent();
    intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
    intent.setData(Uri.parse("package:" + packageName));
    context.startActivity(intent);//from  w  ww .  ja  va2  s  . c  o m
}