当我单击button1将URL打开到浏览器时,应用程序停止。并在调试时我收到此错误:
![throw new ActivityNotFoundException(][1]
"No Activity found to handle " + intent);
这就是代码:
package com.example.outroprojeto;
//
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class AtividadePrincipal extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_atividade_principal);
addButtonClickListner();
}
public void addButtonClickListner()
{
Button btnNavigator = (Button)findViewById(R.id.button1);
btnNavigator.setOnClickListener(new OnClickListener(){
public void onClick(View arg)
{
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.satalaj.com"));
startActivity(intent);
}
});
}
}
这里你可以看到调试屏幕
答案 0 :(得分:0)
尝试使用XML。在Xml中创建一个buttonon并添加android:onClick =" browseWeb"然后在Java活动中添加以下代码。
public void brosweWeb (View view) {
Intent intent = new Intent(Intent.ACTION_VIEW
Uri.parse("web address here"));
startActivity(intent);