【发布时间】:2018-03-01 05:51:12
【问题描述】:
我尝试通过单击按钮打开网页。但是,它不起作用。 这是我的代码:
ImageButton fbButton = (ImageButton) findViewById(R.id.fb);
fbButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent viewIntent = new Intent("Intent.ACTION_VIEW", Uri.parse("http://www.facebook.com"));
startActivity(viewIntent);
}
});
它总是会捕获语句。
这里是Manifest文件权限代码:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
错误日志:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.krish.me, PID: 4532
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=Intent.ACTION_VIEW dat=http://www.facebook.com }
提前谢谢你:)
【问题讨论】: