case0. Intent.parseUri() (Uri안에 있는 Extra Parsing Type)
Intent.class 참조
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add EXTRA | |
if (uri.startsWith("S.", i)) b.putString(key, value); | |
else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value)); | |
else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value)); | |
else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0)); | |
else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value)); | |
else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value)); | |
else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value)); | |
else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value)); | |
else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value)); | |
else throw new URISyntaxException(uri, "unknown EXTRA type", i); |
case1. class 호출(명시적)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String uri = "intent:#Intent;component=패키지명/.세부패키지명.클래스명;i.data=인트형데이터;end"; | |
Intent intent = new Intent(); | |
try { | |
intent = Intent.parseUri(uri, 0); | |
} catch (URISyntaxException e) { | |
e.printStackTrace(); | |
} | |
startActivity(intent); |
case2. class 호출(암시적)
반드시 Manifest에서 받는 class부분의 intent-filter에서 action을 정의해 주어야함
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<intent-filter> | |
<action android:name="액션명"></action> | |
<category android:name="android.intent.category.DEFAULT"></category> | |
</intent-filter> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String uri = "intent:#Intent;action=액션명;S.data=문자형데이터;end"; | |
Intent intent = new Intent(); | |
try { | |
intent = Intent.parseUri(uri, 0); | |
} catch (URISyntaxException e) { | |
e.printStackTrace(); | |
} | |
startActivity(intent); |
case3. 특정 url 이동(Web)
반드시 Manifest에서 받는 class부분의 intent-filter에서 action을 정의해 주어야함
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<intent-filter> | |
<action android:name="android.intent.action.VIEW"></action> | |
<category android:name="android.intent.category.BROWSABLE"></category> | |
<category android:name="android.intent.category.DEFAULT"></category> | |
<data android:scheme="스키마이름"></data> | |
</intent-filter> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String uri = "http://웹주소#Intent;launchFlags=0x10000000;end"; | |
// 0x10000000 = FLAG_ACTIVITY_NEW_TASK | |
Intent intent = new Intent(); | |
try { | |
intent = Intent.parseUri(uri, 0); | |
} catch (URISyntaxException e) { | |
e.printStackTrace(); | |
} | |
startActivity(intent); |
'Android' 카테고리의 다른 글
[android]EditText without cursor _ EditText에서 커서 제거 (0) | 2014.02.06 |
---|---|
[android]source code에서 투명한 화면 만들기 (0) | 2013.11.06 |
[android]Bitmap 이미지 후광효과(BlurMaskFilter, extractAlpha) (2) | 2013.07.29 |
[android]fragment show(visible) & hide(gone) (0) | 2013.07.22 |
[android]WebView history stack & back (0) | 2013.05.29 |