《第一行代码》隐式Intent的用法中跳转百度页面和拨号界面的都崩了,新手,求指导。

《第一行代码》隐式Intent的用法中跳转百度页面和拨号界面的都崩了,新手,求指导。

问题描述:

button1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Intent intent = new Intent("Intent.ACTION_DIAL");
intent.setData(Uri.parse("tel:10086"));
startActivity(intent);
}
});

    <activity android:name=".ThirdActivity">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="http" />
        </intent-filter>
</activity>

    运行时点一下button1就崩

把"Intent.ACTION_DIAL"换成Intent.ACTION_DIAL。

02-27 14:52:17.234 8630-8630/com.example.activitytest E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.activitytest, PID: 8630
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=Intent.ACTION_VIEW dat=http://baidu.com }
这个是没有活动可以响应Intent的意思吗?可是ThirdAcitvity应该响应才对啊啊啊啊,没写错啊。

Data的字符串格式为:tel://telnumber。修改如下试一下呢:intent.setData(Uri.parse("tel://10086"));

DATad的格式不正确

//打开电话
Intent intent =new Intent(Intent.ACTION_DIAL,Uri.parse("tel:10086"));
startActivity(intent);
//打开百度
Intent intent =new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.baidu.com"));
startActivity(intent);
直接粘入点击事件即可

new Intent("Intent.ACTION_DIAL") 这里不要加引号.