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 sendBroadCast(Context context, String action, String key, String value) {
    Intent intent = new Intent();
    intent.setAction(action);//www  .j av a 2  s . co m
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.putExtra(key, value);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void shareImage(Context context, Uri uri, String title) {
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    shareIntent.setType("image/jpeg");
    context.startActivity(Intent.createChooser(shareIntent, title));
}

From source file:Main.java

public static void downloadApkFromBrower(Context context, String url) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    Uri content_url = Uri.parse(url);/*from   w ww . j  a va 2s  .  c  o  m*/
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setData(content_url);
    context.startActivity(intent);
}

From source file:Main.java

public static void callText(Context context, String path) {
    Intent intent = new Intent();
    intent.setDataAndType(Uri.fromFile(new File(path)), "text/plain");
    context.startActivity(intent);/*w w  w .j a va  2 s  . co  m*/
}

From source file:Main.java

public static void callImage(Context context, String path) {
    Intent intent = new Intent();
    intent.setDataAndType(Uri.fromFile(new File(path)), "image/*");
    context.startActivity(intent);/*from ww  w  .j av a  2  s  . c o  m*/
}

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  www .  j  ava2  s.c o  m
}

From source file:Main.java

public static String unInstallBySys(Context context, String pckName) {
    Intent intent = new Intent();
    Uri uri = Uri.parse("package:" + pckName);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(Intent.ACTION_DELETE);
    intent.setData(uri);//from  w w  w .jav  a  2  s.c o m
    context.startActivity(intent);
    return null;
}

From source file:Main.java

private static void uninstallAppByClick(Context context, String pkgName) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_DELETE);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setData(Uri.parse("package:" + pkgName));
    context.startActivity(intent);/*from   w  w  w  .  ja v a2 s .  com*/
}

From source file:Main.java

public static void shareViaSms(Context context, String subject, String text) {
    Intent intent = new Intent();
    intent.setType("text/plain");
    intent.setData(Uri.parse("sms:"));
    intent.setAction(Intent.ACTION_VIEW);
    intent.putExtra("sms_body", text);
    context.startActivity(Intent.createChooser(intent, "Share via SMS"));
}

From source file:Main.java

public static void gotoActivity(Activity curActivity, Class<?> targetActivity, boolean finish) {
    Intent intent = new Intent();
    intent.setClass(curActivity, targetActivity);
    curActivity.startActivity(intent);/*  w ww . j  a  v  a2  s  .com*/
    //      curActivity.overridePendingTransition(R.anim.slide_left_in,
    //            R.anim.slide_left_out);

    if (finish) {
        curActivity.finish();
    }
}