설.현.아빠
[개발 Tip] 마켓에서 패키지명에 해당하는 어플 찾도록 StartActivity 시키기 본문
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith(SCHEME_WTAI)) {
// wtai://wp/mc;number
// number=string(phone-number)
if (url.startsWith(SCHEME_WTAI_MC)) {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(WebView.SCHEME_TEL +
url.substring(SCHEME_WTAI_MC.length())));
startActivity(intent);
return true;
}
// wtai://wp/sd;dtmf
// dtmf=string(dialstring)
if (url.startsWith(SCHEME_WTAI_SD)) {
// TODO
// only send when there is active voice connection
return false;
}
// wtai://wp/ap;number;name
// number=string(phone-number)
// name=string
if (url.startsWith(SCHEME_WTAI_AP)) {
// TODO
return false;
}
}
// The "about:" schemes are internal to the browser; don't
// want these to be dispatched to other apps.
if (url.startsWith("about:")) {
return false;
}
Intent intent;
// perform generic parsing of the URI to turn it into an Intent.
try {
intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
} catch (URISyntaxException ex) {
Log.w("Browser", "Bad URI " + url + ": " + ex.getMessage());
return false;
}
// check whether the intent can be resolved. If not, we will see
// whether we can download it from the Market.
if (getPackageManager().resolveActivity(intent, 0) == null) {
String packagename = intent.getPackage();
if (packagename != null) {
intent = new Intent(Intent.ACTION_VIEW, Uri
.parse("market://search?q=pname:" + packagename));
intent.addCategory(Intent.CATEGORY_BROWSABLE);
startActivity(intent);
return true;
} else {
return false;
}
}
// sanitize the Intent, ensuring web pages can not bypass browser
// security (only access to BROWSABLE activities).
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setComponent(null);
try {
if (startActivityIfNeeded(intent, -1)) {
return true;
}
} catch (ActivityNotFoundException ex) {
// ignore the error. If no application can handle the URL,
// eg about:blank, assume the browser can handle it.
}
if (mMenuIsDown) {
openTab(url);
closeOptionsMenu();
return true;
}
return false;
}
'안드로이드 > Market' 카테고리의 다른 글
안드로이드마켓 MultipleScreens 삽질..(갤노트와 갤S2) (0) | 2012.02.16 |
---|---|
어플리케이션 서명에서 마켓 배포!!! (0) | 2011.02.11 |
Application Update시 버전 정보 보여주기 (0) | 2011.02.11 |
안드로이드 개발 App 단말에 Upload & 배포 & 안드로이드 개발자 등록 (0) | 2011.02.11 |