Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7414423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:05:54+00:00 2026-05-29T07:05:54+00:00

I am developing an android app which has a button in one activity and

  • 0

I am developing an android app which has a button in one activity and when user clicks that button it should create another activity which should show all my contact information in my own ListView.
My code is as follows

package com.softtrends.practice.contactmanager;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ContactManagerActivity extends Activity implements OnClickListener{
final int PICK_CONTACT_REQUEST=1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final Button contacts=(Button) findViewById(R.id.contacts);
    contacts.setOnClickListener(this);
}
@Override
public void onClick(View v){
    Intent contactIntent = new Intent(this, ContactsActivity.class);
    startActivity(contactIntent);
}
}

package com.softtrends.practice.contactmanager;

import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.PhoneLookup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ContactsActivity extends ListActivity {
private Cursor cur;
private String names[];
private void getData(){
    cur = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, 
                              null, null,null, null);
    startManagingCursor(cur);
    names=new String[cur.getCount()];
    int nameCol=cur.getColumnIndex(PhoneLookup.DISPLAY_NAME);
    int i=0;
    while(cur.moveToNext()){
        names[i]=cur.getString(nameCol);
        System.out.println(names[i]);
        i++;
    }
    cur.close();
}
public void onCreate(Bundle bundle){
    super.onCreate(bundle);
getData();
    setListAdapter(new ArrayAdapter<String>(this, R.layout.list_view, names));

    ListView lv=getListView();
    lv.setTextFilterEnabled(true);
} 
}

While running this app, it displays the first activity as expected but when I click the button, Force close error is coming and in the logcat the error is showing at the line where I am calling the query method.

My logcat is

 01-25 14:07:05.239: DEBUG/dalvikvm(127): GC_EXPLICIT freed 179 objects / 9288 bytes in 163ms
    01-25 14:07:09.249: INFO/ActivityManager(59): Starting activity: Intent{ cmp=  com.softtrends.practice.contactmanager/.ContactsActivity }
    01-25 14:07:09.389: ERROR/DatabaseUtils(164): Writing exception to parcel
    01-25 14:07:09.389: ERROR/DatabaseUtils(164): java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/contacts from pid=386, uid=10040 requires android.permission.READ_CONTACTS
    01-25 14:07:09.389: ERROR/DatabaseUtils(164):     at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:271)
    01-25 14:07:09.389: ERROR/DatabaseUtils(164):     at android.content.ContentProvider$Transport.bulkQuery(ContentProvider.java:149)
    01-25 14:07:09.389: ERROR/DatabaseUtils(164):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:111)
    01-25 14:07:09.389: ERROR/DatabaseUtils(164):     at android.os.Binder.execTransact(Binder.java:288)
    01-25 14:07:09.389: ERROR/DatabaseUtils(164):     at dalvik.system.NativeStart.run(Native Method)
    01-25 14:07:09.389: DEBUG/AndroidRuntime(386): Shutting down VM
    01-25 14:07:09.389: WARN/dalvikvm(386): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386): FATAL EXCEPTION: main
    01-25 14:07:09.420: ERROR/AndroidRuntime(386): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.softtrends.practice.contactmanager/com.softtrends.practice.contactmanager.ContactsActivity}: java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/contacts from pid=386, uid=10040 requires android.permission.READ_CONTACTS
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.os.Handler.dispatchMessage(Handler.java:99)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.os.Looper.loop(Looper.java:123)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.app.ActivityThread.main(ActivityThread.java:4627)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at java.lang.reflect.Method.invokeNative(Native Method)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at java.lang.reflect.Method.invoke(Method.java:521)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at dalvik.system.NativeStart.main(Native Method)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386): Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/contacts from pid=386, uid=10040 requires android.permission.READ_CONTACTS
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.os.Parcel.readException(Parcel.java:1247)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:330)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.content.ContentResolver.query(ContentResolver.java:245)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at com.softtrends.practice.contactmanager.ContactsActivity.onCreate(ContactsActivity.java:29)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    01-25 14:07:09.420: ERROR/AndroidRuntime(386):     ... 11 more
    01-25 14:07:09.439: WARN/ActivityManager(59):   Force finishing activity com.softtrends.practice.contactmanager/.ContactsActivity
    01-25 14:07:09.439: WARN/ActivityManager(59):   Force finishing activity com.softtrends.practice.contactmanager/.ContactManagerActivity
    01-25 14:07:09.579: DEBUG/dalvikvm(59): GC_FOR_MALLOC freed 11214 objects / 557344 bytes in 116ms
    01-25 14:07:09.839: DEBUG/SntpClient(59): request time failed: java.net.SocketException: Address family not supported by protocol
    01-25 14:07:09.980: WARN/ActivityManager(59): Activity pause timeout for HistoryRecord{450d30d0 com.softtrends.practice.contactmanager/.ContactsActivity}
    01-25 14:07:15.710: DEBUG/dalvikvm(164): GC_EXPLICIT freed 121 objects / 13752 bytes in 148ms
    01-25 14:07:20.443: WARN/ActivityManager(59): Activity destroy timeout for HistoryRecord{4509d8d0 com.softtrends.practice.contactmanager/.ContactManagerActivity}
    01-25 14:07:20.443: WARN/ActivityManager(59): Activity destroy timeout for HistoryRecord{450d30d0 com.softtrends.practice.contactmanager/.ContactsActivity}

some may think that as per the logcat it requires READ_CONTACTS permission. But let me tell all that I have already set this permission in my menifest file. Here is my manifest file.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.softtrends.practice.contactmanager"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<user-permission android:name="android.permission.READ_CONTACTS"/>
<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".ContactManagerActivity"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".ContactsActivity"></activity>
</application>
</manifest>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:05:55+00:00Added an answer on May 29, 2026 at 7:05 am

    Thank God finally I got the answer, it’s a silly mistake, the answer is instead of uses-permission tag I used user-permission tag in the manifest file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a playlist app for Android which has a ListView that contains
I am developing an android app where a user has to enter his login
I'm developing an android app that has a bunch of screens (activities) that are
I am developing an Android app. It has a login page in which I
I am developing an android app in which I have to present the user
I am developing an android app which has Facebook integration in it. I have
I am developing an Android app which needs to poll a specific webpage in
I'm developing a funny quotes app for android. I have over 1000 quotes which
I am developing an android app which requires search functionality. My app contains action
Currently I'm developing an Android app which draws a point on the coordinates input

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.