我有3项活动——A、B和C。 关于活动B,我有一个纽芬兰语区,开放活动C(网站浏览器),其代码如下:
buyButton = (Button) findViewById(R.id.buyButton);
buyButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
System.out.println("!!! buy !!!");
/*Uri uri = Uri.parse("http://www.google.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);*/
Intent startActivity = new Intent(getApplicationContext(), WebViewer.class);
startActivity.putExtra("link","http://www.google.com");
startActivityForResult(startActivity, 15);
}
});
现在,当我在网上浏览器活动C时,活动B也关闭。 我不肯定为什么发生这种情况。 任何方面? 感谢。
网址浏览器代码:
public class WebViewer extends Activity {
ImageButton backButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.streams);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title3);
String url = "";
Bundle extras = getIntent().getExtras();
if(extras !=null) {
url = extras.getString("link");
}
if (!url.startsWith("http://") && !url.startsWith("https://"))
url = "http://" + url;
final TextView title=(TextView) findViewById(R.id.title_text_view_success3);
//title.setText("Saved Streams");
backButton = (ImageButton) findViewById(R.id.back_button3);
backButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
System.out.println("!!! BACK !!!");
//finishActivity(0);
onBackPressed();
}
});
setContentView(R.layout.viewer);
final WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
title.setText("Loading...");
WebViewer.this.setProgress(progress * 100);
if(progress == 100)
title.setText(webView.getTitle());
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
// Handle the error
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
webView.loadUrl(url);
}
}