我对 Eclipse 还是很陌生,我已经尝试了一切来防止这些错误发生:
06-30 00:38:28.773: E/AndroidRuntime(20520): FATAL EXCEPTION: main
06-30 00:38:28.773: E/AndroidRuntime(20520): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxx cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{4157fb20 20520:com.mshaw.avanos/10174} (pid=20520, uid=10174) requires android.permission.CALL_PHONE
06-30 00:38:28.773: E/AndroidRuntime(20520): at android.os.Parcel.readException(Parcel.java:1332)
06-30 00:38:28.773: E/AndroidRuntime(20520): at android.os.Parcel.readException(Parcel.java:1286)
06-30 00:38:28.773: E/AndroidRuntime(20520): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1691)
06-30 00:38:28.773: E/AndroidRuntime(20520): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1505)
06-30 00:38:28.773: E/AndroidRuntime(20520): at android.app.Activity.startActivityForResult(Activity.java:3244)
06-30 00:38:28.773: E/AndroidRuntime(20520): at android.app.Activity.startActivity(Activity.java:3351)
06-30 00:38:28.773: E/AndroidRuntime(20520): at com.mshaw.avanos.AvanosActivity.onClick(AvanosActivity.java:34)
06-30 00:38:28.773: E/AndroidRuntime(20520): at android.view.View.performClick(View.java:3549)
06-30 00:38:28.773: E/AndroidRuntime(20520): at android.view.View$PerformClick.run(View.java:14400)
06-30 00:38:28.773: E/AndroidRuntime(20520): at android.os.Handler.handleCallback(Handler.java:605)
06-30 00:38:28.773: E/AndroidRuntime(20520): at android.os.Handler.dispatchMessage(Handler.java:92)
06-30 00:38:28.773: E/AndroidRuntime(20520): at android.os.Looper.loop(Looper.java:154)
06-30 00:38:28.773: E/AndroidRuntime(20520): at android.app.ActivityThread.main(ActivityThread.java:4894)
06-30 00:38:28.773: E/AndroidRuntime(20520): at java.lang.reflect.Method.invokeNative(Native Method)
06-30 00:38:28.773: E/AndroidRuntime(20520): at java.lang.reflect.Method.invoke(Method.java:511)
06-30 00:38:28.773: E/AndroidRuntime(20520): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-30 00:38:28.773: E/AndroidRuntime(20520): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-30 00:38:28.773: E/AndroidRuntime(20520): at dalvik.system.NativeStart.main(Native Method)
第一个错误让我很感兴趣,因为我已经提供了许可。这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mshaw.avanos"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.PHONE_CALL" />
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="@drawable/avanos_logo"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<activity
android:name=".AvanosActivity"
android:label="@string/app_name"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />L
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Password"
android:label="@string/settings">
</activity>
</application>
这是导致整个混乱的主要活动的一部分:
/** Called when the activity is first created. */
private Button button1;
private EditText editText1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button1 = (Button)findViewById(R.id.button1);
setEditText1((EditText)findViewById(R.id.editText1));
button1.setOnClickListener(this); {}}
public void onClick(View arg0) {
EditText num=(EditText)findViewById(R.id.editText1);
String number = "tel:" +num.getText().toString().trim();
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(number));
startActivity(callIntent);
}
有任何想法吗?