这个错误怎么解决,新手
04-15 05:35:16.563: E/AndroidRuntime(894): FATAL EXCEPTION: main04-15 05:35:16.563: E/AndroidRuntime(894): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.contract/com.contract.ContractActivity}: java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/contacts from pid=894, uid=10036 requires android.permission.READ_CONTACTS
04-15 05:35:16.563: E/AndroidRuntime(894): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-15 05:35:16.563: E/AndroidRuntime(894): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-15 05:35:16.563: E/AndroidRuntime(894): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-15 05:35:16.563: E/AndroidRuntime(894): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-15 05:35:16.563: E/AndroidRuntime(894): at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 05:35:16.563: E/AndroidRuntime(894): at android.os.Looper.loop(Looper.java:123)
04-15 05:35:16.563: E/AndroidRuntime(894): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-15 05:35:16.563: E/AndroidRuntime(894): at java.lang.reflect.Method.invokeNative(Native Method)
04-15 05:35:16.563: E/AndroidRuntime(894): at java.lang.reflect.Method.invoke(Method.java:507)
04-15 05:35:16.563: E/AndroidRuntime(894): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-15 05:35:16.563: E/AndroidRuntime(894): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-15 05:35:16.563: E/AndroidRuntime(894): at dalvik.system.NativeStart.main(Native Method)
04-15 05:35:16.563: E/AndroidRuntime(894): Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/contacts from pid=894, uid=10036 requires android.permission.READ_CONTACTS
04-15 05:35:16.563: E/AndroidRuntime(894): at android.os.Parcel.readException(Parcel.java:1322)
04-15 05:35:16.563: E/AndroidRuntime(894): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160)
04-15 05:35:16.563: E/AndroidRuntime(894): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
04-15 05:35:16.563: E/AndroidRuntime(894): at android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:330)
04-15 05:35:16.563: E/AndroidRuntime(894): at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
04-15 05:35:16.563: E/AndroidRuntime(894): at android.content.ContentResolver.query(ContentResolver.java:262)
04-15 05:35:16.563: E/AndroidRuntime(894): at com.contract.ContractActivity.onCreate(ContractActivity.java:18)
04-15 05:35:16.563: E/AndroidRuntime(894): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-15 05:35:16.563: E/AndroidRuntime(894): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-15 05:35:16.563: E/AndroidRuntime(894): ... 11 more --------------------编程问答-------------------- package com.contract;
import android.app.Activity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.PhoneLookup;
import android.widget.TextView;
public class ContractActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
TextView tv=new TextView(this);
String string="";
super.onCreate(savedInstanceState);
ContentResolver cr=getContentResolver();
Cursor cursor=cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
while(cursor.moveToNext())
{
int nameFiledColumnIndex=cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME);
String contact=cursor.getString(nameFiledColumnIndex);
int numberFieldColumnIndex=cursor.getColumnIndex(PhoneLookup.NUMBER);
String number=cursor.getString(numberFieldColumnIndex);
string+=(contact+":"+number+'\n');
}
cursor.close();
tv.setText(string);
setContentView(tv);
}
} --------------------编程问答-------------------- 提示很清楚,读取电话号码需要配置android.permission.READ_CONTACTS 权限,在manifest.xml中 --------------------编程问答-------------------- 楼上已经说明白了,那我就不罗嗦了 --------------------编程问答-------------------- Permission Denial: reading com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts
需要2L,提到的权限 --------------------编程问答-------------------- <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.helloworld"
android:versionCode="1"
android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".HelloworldActivity"
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>
</manifest>
我已经加了的 --------------------编程问答-------------------- 加完后现在运行是什么错误提示?
补充:移动开发 , Android