我试图在我的应用程序中夸大webview。当我点击浏览器启动但应用程序崩溃时: webview完成加载,然后应用程序崩溃
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);
}
});
}
错误:
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 }
你能帮帮我吗?
谢谢
答案 0 :(得分:2)
如果您在模拟器上运行此应用程序,应用程序将崩溃,因为未安装“Play商店”应用程序。在运行之前,请确保您的设备已安装了Play商店。