问题描述
- 跪求各位大神,帮忙新菜鸟解决这个问题。谢谢!!
- 报错原因: 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 {@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button=(Button) this.findViewById(R.id.button); button.setOnClickListener(new ButtonClickListener());}@Overridepublic 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>
解决方案
tel
后面要有冒号哦
时间: 2024-09-17 23:26:46