Android 单击webview
我正在尝试在我的应用程序中膨胀webview。当我单击浏览器启动但应用程序崩溃时: webview将完成加载,然后应用程序将崩溃Android 单击webview,android,webview,Android,Webview,我正在尝试在我的应用程序中膨胀webview。当我单击浏览器启动但应用程序崩溃时: webview将完成加载,然后应用程序将崩溃 viewGroup = (ViewGroup)activity.findViewById(android.R.id.content); activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); final TextView textView
viewGroup = (ViewGroup)activity.findViewById(android.R.id.content);
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
final TextView textViewCompteur ;
ImageView ic_close ;
final View inflater = activity.getLayoutInflater().inflate(R.layout.interstitial_ads, null, true);
webView = (WebView)inflater.findViewById(R.id.webViewSplashAds);
ic_close = (ImageView)inflater.findViewById(R.id.imageViewCloseSplashAds);
textViewCompteur = (TextView)inflater.findViewById(R.id.textViewSplashAds);
webView.setWebChromeClient(new WebChromeClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.setClickable(true);
webView.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
AppehourTools.disableAdsScroll(webView);
// icone de fermeture
ic_close.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
viewGroup.removeView(inflater);
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
showBar();
}
});
webView.setBackgroundColor(Color.BLACK);
webView.loadData("<html><head><style type=\"text/css\">body{margin:0 auto;text-align:center;}</style></head><body>"
+ array.get(0).getUrl()
+ "</body></html>", "text/html", "utf8");
Log.d("AppehourInterstitialAds", "showing ad");
hideBar();
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
int delayClose;
delayClose = Integer.valueOf(array.get(0).getValidDelay());
viewGroup.addView(inflater);
new CountDownTimer(delayClose * 1000, 1000) {
public void onTick(long millisUntilFinished) {
textViewCompteur.setText(millisUntilFinished / 1000
+ " "
+ context.getString(R.string.seconds_remaining));
}
public void onFinish() {
viewGroup.removeView(inflater);
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
showBar();
}
}.start();
}
public boolean shouldOverrideUrlLoading(WebView view, String url) {
hideBar();
viewGroup.removeView(inflater);
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
//i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(i);
return super.shouldOverrideUrlLoading(view, url);
}
});
}
你能帮我吗?
谢谢如果您在emulator上运行此应用程序,则该应用程序将崩溃,因为未安装“Play Store”应用程序。运行此操作之前,请确保您的设备已安装play store。您需要为该url安装市场应用程序。
03-31 09:39:14.278: W/System.err(1825): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=air.com.goodgamestudios.empirefourkingdoms&referrer=mat_click_id=c5e82ec15ac735af3b-20140331-4066 }