Example usage for android.content Intent setData

List of usage examples for android.content Intent setData

Introduction

In this page you can find the example usage for android.content Intent setData.

Prototype

public @NonNull Intent setData(@Nullable Uri data) 

Source Link

Document

Set the data this intent is operating on.

Usage

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);/*from  ww  w . jav  a 2  s.  c  om*/
    intent.setData(content_url);
    context.startActivity(intent);
}

From source file:Main.java

/**
 * Add file photo to gallery after capture from camera or downloaded.
 *
 * @param context//from  ww  w  .j  a v  a  2  s.  c  o  m
 * @param file
 */
public static void galleryAddPic(Context context, File file) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    Uri contentUri = Uri.fromFile(file);
    mediaScanIntent.setData(contentUri);
    context.sendBroadcast(mediaScanIntent);
}

From source file:Main.java

public static void downApkFromBrowser(Context context, String strUrl) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");

    Uri uri = Uri.parse(strUrl);//from   w  w w .j a  v a2 s  .co m
    intent.setData(uri);

    context.startActivity(intent);
}

From source file:Main.java

public static void link(Context context, String url) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_BROWSABLE);
    intent.setData(Uri.parse(url));
    context.startActivity(intent);//from ww  w  .j  a  va 2  s.  c  om
}

From source file:Main.java

public static void startExplorer(Context context, String url) {
    if (url == null) {
        return;//w w w  .  j ava  2s  .c  o  m
    }
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    Uri content_url = Uri.parse(url);
    intent.setData(content_url);
    context.startActivity(intent);
}

From source file:Main.java

/**
 * Returns an intent to display the message identified by the provided URI in K-9 Mail.
 *
 * @param context/* ww  w .j a va  2 s .c  o m*/
 *         Used to retrieve the package manager.
 * @param emailUri
 *         The URI that identified the message to be displayed.
 *
 * @return An intent to start K-9 Mail's main activity, or {@code null} in case of an error.
 */
public static final Intent getViewMessageIntent(Context context, String emailUri) {
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setPackage(PACKAGE_NAME);
        intent.setData(Uri.parse(emailUri));
        return intent;
    } catch (Exception e) {
        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);/* w  ww  . j  ava2 s .c  o m*/
}

From source file:com.app.common.util.IntentUtils.java

public static void startWebActivity(Context context, String url) {
    final Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));
    context.startActivity(intent);/* w w  w.j av  a 2s . c o  m*/
}

From source file:Main.java

public static void sendEmail(Context ctx, String[] emailAddresses, String[] CCAddresses, String subject,
        String message) {/* w  w  w  . ja  va2s.com*/

    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    // emailIntent.setType("text/plain");
    emailIntent.setData(Uri.parse("mailto:"));
    String[] to = emailAddresses;
    String[] cc = CCAddresses;
    emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
    if (CCAddresses != null) {
        emailIntent.putExtra(Intent.EXTRA_CC, cc);
    }
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(Intent.EXTRA_TEXT, message);
    emailIntent.setType("message/rfc822");

    ctx.startActivity(Intent.createChooser(emailIntent, "Email"));

}

From source file:Main.java

/**
 * Creates implicit intent to open entry of app "OI Notepad" in device's appstore client. 
 * /*from w ww.j a v  a 2s  .com*/
 * @return Intent to open entry of "OI Notepad" on appstore client.
 */
protected static Intent createIntentForOINotepadAppstoreEntry() {

    Uri uri = Uri.parse("market://details?id=" + APPID_OF_OPENINTENT_NOTEPAD);
    final Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(uri);

    return intent;
}