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

protected Intent(Parcel in) 

Source Link

Usage

From source file:Main.java

public static void openSourceURL(Activity activity, String title, String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri uri = Uri.parse(url);/* w  ww. ja v  a2 s .c om*/
    intent.setData(uri);
    activity.startActivity(Intent.createChooser(intent, title));
}

From source file:Main.java

public static void forwardBySms(Context context, String body) {
    if (body != null) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setType("vnd.android-dir/mms-sms");
        // intent.putExtra("forwarded_message",true);
        // comment this may improve performance for forwarding sms
        intent.putExtra("sms_body", body);
        context.startActivity(intent);//from   w  w  w  .j  av a  2s .  co  m
    }
}

From source file:Main.java

public static void showMarketProductBuyPackage(Context context, String pack) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("market://details?id=" + pack));
    context.startActivity(intent);//  w w w . j a v a2  s  .  c o  m
}

From source file:Main.java

public static void installApp(Context context, File file) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    context.startActivity(intent);//from  ww  w . jav  a  2s .co m
}

From source file:Main.java

public static void installApk(Context context, File file) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    context.startActivity(intent);/*from w ww .ja  v a  2 s. co m*/
}

From source file:Main.java

public static void setBadgeOfMadMode(Context context, int count, String packageName, String className) {
    Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
    intent.putExtra("badge_count", count);
    intent.putExtra("badge_count_package_name", packageName);
    intent.putExtra("badge_count_class_name", className);
    context.sendBroadcast(intent);/* www . ja v  a  2s.  co  m*/
}

From source file:Main.java

public static void shareViaEmail(Context context, String subject, String text) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setType("text/html");
    intent.setData(Uri.parse("mailto:"));
    intent.putExtra(Intent.EXTRA_TEXT, text);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    context.startActivity(Intent.createChooser(intent, "Share via Email"));
}

From source file:Main.java

public static Intent makeTakePicturesIntent(File file) {
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
    return intent;
}

From source file:Main.java

public static void install(Context context, String filePath) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.fromFile(new File(filePath)), "application/vnd.android.package-archive");
    context.startActivity(intent);/*w w  w.  ja  v a 2 s  .co m*/
}

From source file:Main.java

public static void enableRequest(Activity activity, int requestCode) {
    Intent btOn = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
    activity.startActivityForResult(btOn, requestCode);
}