public class MyPhoneGapActivity extends DroidGap {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
loadUrl("file:///android_asset/www/test2.html");
appView.getSettings().setJavaScriptEnabled(true);
// appView.setWebViewClient(new MyWebViewClient());
}
private class MyWebViewClient extends WebViewClient {
public static final String INTENT_PROTOCOL_START = "intent:";
public static final String INTENT_PROTOCOL_INTENT = "#Intent;";
public static final String INTENT_PROTOCOL_END = ";end;";
public static final String GOOGLE_PLAY_STORE_PREFIX = "market://details?id=";
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith(INTENT_PROTOCOL_START)) {
final int customUrlStartIndex = INTENT_PROTOCOL_START.length();
final int customUrlEndIndex = url.indexOf(INTENT_PROTOCOL_INTENT);
if (customUrlEndIndex < 0) {
return false;
} else {
final String customUrl = url.substring(customUrlStartIndex, customUrlEndIndex);
try {
getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(customUrl)));
} catch (ActivityNotFoundException e) {
final int packageStartIndex = customUrlEndIndex + INTENT_PROTOCOL_INTENT.length();
final int packageEndIndex = url.indexOf(INTENT_PROTOCOL_END);
final String packageName = url.substring(packageStartIndex, packageEndIndex < 0 ? url.length() : packageEndIndex);
getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(GOOGLE_PLAY_STORE_PREFIX + packageName)));
}
return true;
}
} else {
return false;
}
}
}
하이브리드 어플 phonegap 환경에서
위의 코드를 활용하려 했으나 사용하는법을 모르겠습니다.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
loadUrl("file:///android_asset/www/test2.html");
appView.getSettings().setJavaScriptEnabled(true);
// appView.setWebViewClient(new MyWebViewClient());
}
이런식으로 호출하려고 해봐도 어플로 구동시킨 결과
The connection to the server was unsuccessful 에러와 함께 구동이 되지 않습니다.
빠른 시일내에 연락 바랍니다 ㅜㅜ