跪求各位大神,帮忙新菜鸟解决这个问题。谢谢!!

报错原因: E/AndroidRuntime(867): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CALL dat=tel5556 }
源代码如下:

//mainactivity代码
public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button button=(Button) this.findViewById(R.id.button);
    button.setOnClickListener(new ButtonClickListener());
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
private final class ButtonClickListener implements View.OnClickListener{

    @Override
    public void onClick(View v) {
        Intent intent=new Intent();
        EditText editContent=(EditText) findViewById(R.id.mobile);
        String num=editContent.getText().toString();
        intent.setAction("android.intent.action.CALL");
        intent.setData(Uri.parse("tel"+num));
        MainActivity.this.startActivity(intent);
    }


}

}
//mainfest.xml里的代码
<?xml version="1.0" encoding="utf-8"?>
package="com.lh.phone"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.CALL_PHONE"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.lh.phone.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>

1个回答

tel后面要有冒号哦

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐