336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
Let's take a look at the most common implicit intents such as making a phone call, launching a web address, sending an email, etc.
Phone CallPermissions:
<uses-permission android:name="android.permission.CALL_PHONE" />
Intent:
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:0377778888"));
startActivity(callIntent);
Send Email (to Phone Email Client)Compose an email in the phone email client:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "some@email.address" });
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, "mail body");
startActivity(Intent.createChooser(intent, ""));
Send Email (to Gmail)Gmail does not examine the extra Intent fields, so in order to use this intent, you need to use the Intent.ACTION_SENDTO
and pass a mailto:
URI with the subject and body URL encoded.
String uriText =
"mailto:youremail@gmail.com" +
"?subject=" + Uri.encode("some subject text here") +
"&body=" + Uri.encode("some text here");
Uri uri = Uri.parse(uriText);
Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(uri);
startActivity(Intent.createChooser(sendIntent, "Send email"));
Launch WebsiteLaunch a website in the phone browser:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
Open Google Play StoreOpen app page on Google Play:
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=" + context.getPackageName()));
startActivity(intent);
Compose SMSUri smsUri = Uri.parse("tel:" + to);
Intent intent = new Intent(Intent.ACTION_VIEW, smsUri);
intent.putExtra("address", to);
intent.putExtra("sms_body", message);
intent.setType("vnd.android-dir/mms-sms");
startActivity(intent);
Google MapsShow location in maps application:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
String data = String.format("geo:%s,%s", latitude, longitude);
if (zoomLevel != null) {
data = String.format("%s?z=%s", data, zoomLevel);
}
intent.setData(Uri.parse(data));
startActivity(intent);
Capture PhotoUri uri = Uri.fromFile(new File(file));
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
startActivity(intent);
Sharing ContentImages or binary data:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("image/jpg");
Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
sharingIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
or HTML:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/html");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<p>This is the text shared.</p>"));
startActivity(Intent.createChooser(sharingIntent,"Share using"));
출처 : https://github.com/codepath/android_guides/wiki/Common-Implicit-Intents
// 웹페이지 띄우기
Intent it =
new
Intent(Intent.ACTION_VIEW,uri);
startActivity(it);
// 구글맵 띄우기
Uri uri = Uri.parse(
"geo:38.899533,-77.036476"
);
Intent it =
new
Intent(Intent.Action_VIEW,uri);
startActivity(it);
// 구글 길찾기 띄우기
Intent it =
new
Intent(Intent.ACTION_VIEW,URI);
startActivity(it);
// 전화 걸기
Uri uri = Uri.parse(
"tel:xxxxxx"
);
Intent it =
new
Intent(Intent.ACTION_DIAL, uri);
startActivity(it);
Uri uri = Uri.parse(
"tel.xxxxxx"
);
Intent it =
new
Intent(Intent.ACTION_CALL,uri);
// 퍼미션을 잊지 마세요. <uses-permission id="android.permission.CALL_PHONE">
// SMS/MMS 발송
Intent it =
new
Intent(Intent.ACTION_VIEW);
it.putExtra(
"sms_body"
,
"The SMS text"
);
it.setType(
"vnd.android-dir/mms-sms"
);
startActivity(it);
// SMS 발송
Uri uri = Uri.parse(
"smsto:0800000123"
);
Intent it =
new
Intent(Intent.ACTION_SENDTO, uri);
it.putExtra(
"sms_body"
,
"The SMS text"
);
startActivity(it);
// MMS 발송
Intent it =
new
Intent(Intent.ACTION_SEND);
it.putExtra(
"sms_body"
,
"some text"
);
it.putExtra(Intent.EXTRA_STREAM, uri);
it.setType(
"image/png"
);
startActivity(it);
// 이메일 발송
Uri uri = Uri.parse(
"mailto:xxx@abc.com"
);
Intent it =
new
Intent(Intent.ACTION_SENDTO, uri);
startActivity(it);
Intent it =
new
Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_EMAIL,
"me@abc.com"
);
it.putExtra(Intent.EXTRA_TEXT,
"The email body text"
);
it.setType(
"text/plain"
);
startActivity(Intent.createChooser(it,
"Choose Email Client"
));
Intent it =
new
Intent(Intent.ACTION_SEND);
String[] tos = {
"me@abc.com"
};
String[] ccs = {
"you@abc.com"
};
it.putExtra(Intent.EXTRA_EMAIL, tos);
it.putExtra(Intent.EXTRA_CC, ccs);
it.putExtra(Intent.EXTRA_TEXT,
"The email body text"
);
it.putExtra(Intent.EXTRA_SUBJECT,
"The email subject text"
);
it.setType(
"message/rfc822"
);
startActivity(Intent.createChooser(it,
"Choose Email Client"
));
// extra 추가하기
Intent it =
new
Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT,
"The email subject text"
);
sendIntent.setType(
"audio/mp3"
);
startActivity(Intent.createChooser(it,
"Choose Email Client"
));
// 미디어파일 플레이 하기
Intent it =
new
Intent(Intent.ACTION_VIEW);
it.setDataAndType(uri,
"audio/mp3"
);
startActivity(it);
Uri uri = Uri.withAppendedPath(
MediaStore.Audio.Media.INTERNAL_CONTENT_URI,
"1"
);
Intent it =
new
Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
// 설치 어플 제거
Uri uri = Uri.fromParts(
"package"
, strPackageName,
null
);
Intent it =
new
Intent(Intent.ACTION_DELETE, uri);
startActivity(it);
// APK파일을 통해 제거하기
Uri uninstallUri = Uri.fromParts(
"package"
,
"xxx"
,
null
);
returnIt =
new
Intent(Intent.ACTION_DELETE, uninstallUri);
// APK파일 설치
Uri installUri = Uri.fromParts(
"package"
,
"xxx"
,
null
);
returnIt =
new
Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
// 음악 파일 재생
returnIt =
new
Intent(Intent.ACTION_VIEW, playUri);
// 첨부파일을 추가하여 메일 보내기
Intent it =
new
Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT,
"The email subject text"
);
sendIntent.setType(
"audio/mp3"
);
startActivity(Intent.createChooser(it,
"Choose Email Client"
));
// 마켓에서 어플리케이션 검색
Intent it =
new
Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
// 패키지명은 어플리케이션의 전체 패키지명을 입력해야 합니다.
// 마켓 어플리케이션 상세 화면
Intent it =
new
Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
// 아이디의 경우 마켓 퍼블리싱사이트의 어플을 선택후에 URL을 확인해보면 알 수 있습니다.
// 구글 검색
Intent intent =
new
Intent();
intent.setAction(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY,
"searchString"
)
startActivity(intent);
</uses-permission>
## 이블로그는 어디까지는 찾았던 부분을 잊지 않기 위해 올려놓은 것 입니다.
내용이 부실해도 이해해 주시길 바랍니다.
'나의 플랫폼 > 안드로이드' 카테고리의 다른 글
[Android] ACTION_PICK 사용 (이미지 가져오기) (0) | 2015.11.18 |
---|---|
[Android] ButterKnife Library (0) | 2015.11.18 |
[Android] TabLayout with ViewPager 에서 tab을 클릭 했을 때 (0) | 2015.11.17 |
[Android] Fragment transition 이용시 (2) | 2015.11.17 |
[Android] Tablayout이 보이지 않을 때 (0) | 2015.11.16 |