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 callPhone(Context context, String phone) {
    Intent intent = new Intent(Intent.ACTION_CALL);
    Uri data = Uri.parse("tel:" + phone);
    intent.setData(data);//from w  ww.j av  a 2 s  .  co  m
    context.startActivity(intent);
}

From source file:Main.java

public static boolean isIntentAvailable(Context context, String s) {
    boolean flag;
    if (context.getPackageManager().queryIntentActivities(new Intent(s), 0x10000).size() > 0)
        flag = true;//from w w w  .j  a  va2  s .c  o  m
    else
        flag = false;
    return flag;
}

From source file:Main.java

public static void openAppDetails(Context context, String pkgname) {
    Intent i = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    i.addCategory(Intent.CATEGORY_DEFAULT);
    Uri data = Uri.parse("package:" + pkgname);
    i.setData(data);/*from  www .  j  a v a2s .c o  m*/
    context.startActivity(i);
}

From source file:Main.java

public static void refreshGallery(Context context, Uri uri) {
    Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    final Uri contentUri = uri;
    scanIntent.setData(contentUri);//w  w w  .  j ava  2  s. co  m
    context.sendBroadcast(scanIntent);
}

From source file:Main.java

public static void showSentEmailIntent(Context context, String subject, String body) {
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setType("message/rfc822");
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(Intent.EXTRA_TEXT, body);
    context.startActivity(emailIntent);//from  ww  w .j  a v a 2s .  com
}

From source file:Main.java

public static void openInBrowser(Activity activity, String link) {
    Intent sharingIntent = new Intent(android.content.Intent.ACTION_VIEW);
    sharingIntent.setData(Uri.parse(link));
    activity.startActivity(sharingIntent);
}

From source file:Main.java

public static void installApk(Context context, String apkPath) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.parse("file://" + apkPath), "application/vnd.android.package-archive");
    context.startActivity(intent);//from www. jav  a  2  s. co  m
}

From source file:Main.java

public static Intent getCameraIntent(final Uri saveFileURI) {
    Intent mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    return mIntent.putExtra(MediaStore.EXTRA_OUTPUT, saveFileURI);
}

From source file:Main.java

public static void installApkByPath(Context context, String filePath) {
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive");
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);/*from   w w  w. jav  a 2 s  . co  m*/
}

From source file:Main.java

public static boolean backToHome(Context c) {
    Intent i = new Intent(Intent.ACTION_MAIN);

    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.addCategory(Intent.CATEGORY_HOME);

    c.startActivity(i);/*from   ww w.  java  2s  .  co  m*/

    return true;
}