程序运行时强制关闭
这是实现的拨号的小程序 ,不知道为什么一运行就强制关闭,配置文件中我也加了<uses-permission android:name="android.permission.CALL_PHONE"/> 这句啦 ,不知道是什么问题 ,新手请大侠帮忙 ,十份着急
package mySoft.Phone;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class SharpPhoneActivity extends Activity {
private Button button =null;
private EditText edittext = null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button)findViewById(R.string.button);
edittext = (EditText)findViewById(R.string.mobile);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String phone = edittext.getText().toString();
Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+phone));
startActivity(intent);
}
});
}
}
配置清单文件
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="mySoft.Phone" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".SharpPhoneActivity" 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><uses-permission android:name="android.permission.CALL_PHONE"/> </manifest>