2 u012512022 u012512022 于 2013.10.27 20:33 提问

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

报错原因: 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个回答

songzhiyong1121
songzhiyong1121   2013.11.29 16:46

tel后面要有冒号哦

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!