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 call(String phoneNum, Context context) throws Exception {//TODO tobe test
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_DIAL);
    intent.setData(Uri.parse("tel:" + phoneNum));
    context.startActivity(intent);/*from   ww w  .j  av  a  2  s  .com*/
}

From source file:Main.java

public static void installAPK(Context context, String apkFile) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);

    intent.setDataAndType(Uri.fromFile(new File(apkFile)), "application/vnd.android.package-archive");
    context.startActivity(intent);//from   w w w .  ja va 2  s  . c om
}

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);//w w w .  j  av a2s  .  c o m
    intent.setData(uri);
    context.startActivity(intent);
}

From source file:Main.java

public static void jumpTo(Activity activity, String url) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));/*from   w ww.j  a  v a 2s  .c  o  m*/
    activity.startActivity(intent);
}

From source file:Main.java

public static void callSms(Context context, String number, String content) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SENDTO);
    intent.putExtra("sms_body", content);
    intent.setData(Uri.parse(String.format("smsto:%s", number)));
    context.startActivity(intent);/*from  w  w w.j  a  v  a2 s .  c  om*/
}

From source file:Main.java

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

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);//from  w  w  w  .  j  av  a2  s .c o m
}

From source file:Main.java

public static void openURL(Activity activity, String url) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    Uri content_url = Uri.parse(url);//from  ww w  .  j av  a  2  s .c  o  m
    intent.setData(content_url);
    activity.startActivity(intent);
}

From source file:Main.java

public static void openDefaultBrowser(Context context, String url) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    Uri content_url = Uri.parse(url);// w  ww.  jav  a 2 s  .c  om
    intent.setData(content_url);
    context.startActivity(intent);
}

From source file:Main.java

public static Intent share(final String content) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, content);
    sendIntent.setType("text/plain");
    return sendIntent;
}