2012-06-30 67 views
1

我還是相當新的Eclipse和我想盡一切辦法把這些錯誤的發生:致命異常:main-我不知道什麼是錯

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); 
      } 

什麼想法?

+0

這是什麼**按鈕1 .setOnClickListener(本); {}} **? – Lucifer

+0

我沒有足夠的代表評論看到,因爲這真的不是一個答案,但在未來,你應該設置android:debuggable:「真」 – thebmags

回答

6

有沒有像

<uses-permission android:name="android.permission.PHONE_CALL" />

無權更換

<uses-permission android:name="android.permission.CALL_PHONE" />

這裏是清單供您參考:Manifest.permission

+0

哇,我覺得很蠢,非常感謝你! – user1287195

相關問題