jueves, 27 de agosto de 2015

Android: Usefull intents (phone, email, browser)

Phone
Intent intent = new Intent(Intent.ACTION_CALL);
                intent.setData(Uri.parse("tel:" + phoneNumber)); // "phoneNumber" is a string
                context.startActivity(intent);
Email
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
                        "mailto", email, null)); // "email" is the recipients email address
                emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
                emailIntent.putExtra(Intent.EXTRA_TEXT, "Body");
                context.startActivity(Intent.createChooser(emailIntent, context.getString(R.string.send_email)));
Browser
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(webURL));
                context.startActivity(browserIntent);

No hay comentarios:

Publicar un comentario