This question already has answers here:
How to read contacts on Android 2.0
(9 answers)
Closed 5 years ago.
The following is my code:
Cursor mCursor = this.getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.HAS_PHONE_NUMBER + "==1", null, null);
startManagingCursor(mCursor);
ListAdapter adapter = new SimpleCursorAdapter(this,
R.layout.two_line_list_item, mCursor, new String[] {
PhoneLookup.DISPLAY_NAME, PhoneLookup.NUMBER}, new int[] {R.id.text1, R.id.text2});
setListAdapter(adapter);
I'm able to see the DISPLAY_NAME, but whenever I add PhoneLookup.NUMBER, the application crashes. I also added a condition to select only contacts that have a phone number assuming its crashing due to null data. Still no luck. Is there any permissions I need to add to get the phone number? I already have android.permission.READ_CONTACTS in my manifest.
Logcat output:
I/ActivityManager( 58): Starting activity: Intent { cmp=fourth.app/.food }
D/AndroidRuntime( 335): Shutting down VM
W/dalvikvm( 335): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime( 335): FATAL EXCEPTION: main
E/AndroidRuntime( 335): java.lang.RuntimeException: Unable to start activity ComponentInfo{fourth.app/fourth.app.food}: java.lang.Ille
galArgumentException: column 'number' does not exist
E/AndroidRuntime( 335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
E/AndroidRuntime( 335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime( 335): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime( 335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime( 335): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 335): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 335): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 335): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 335): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 335): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 335): Caused by: java.lang.IllegalArgumentException: column 'number' does not exist
E/AndroidRuntime( 335): at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:314)
E/AndroidRuntime( 335): at android.database.CursorWrapper.getColumnIndexOrThrow(CursorWrapper.java:99)
E/AndroidRuntime( 335): at android.widget.SimpleCursorAdapter.findColumns(SimpleCursorAdapter.java:312)
E/AndroidRuntime( 335): at android.widget.SimpleCursorAdapter.<init>(SimpleCursorAdapter.java:87)
E/AndroidRuntime( 335): at fourth.app.food.onCreate(food.java:21)
E/AndroidRuntime( 335): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime( 335): ... 11 more
W/ActivityManager( 58): Force finishing activity fourth.app/.food
W/ActivityManager( 58): Force finishing activity fourth.app/.four
W/ActivityManager( 58): Activity pause timeout for HistoryRecord{43f54e88 fourth.app/.food}
java.lang.IllegalArgumentException: column 'number' does not exist
You are using an invalid name of column.
have a look at this question: How to read contacts on Android 2.0
Related
I am creating a new account using AccountManager and it works fine for android 2.3+ but for android 2.1 it makes the phone's address-book crash when trying to view a contact details.
The account is defined like this:
type: com.example.android.authenticators.ABCAuthenticator.account
name: Contacts ABC
The crash I see when trying to open a contact's detail activity (not on my app, which works fine, but on the Motorola 2.1's native contacts app) is:
V/ContactsListActivity( 1667): onListItemClick :Uri = content://com.android.contacts/contacts/lookup/0r42-29292929/42
I/ActivityManager( 1017): Starting activity: Intent { act=android.intent.action.VIEW dat=content://com.android.contacts/contacts/lookup/0r42-29292929/42 cmp=com.android.contacts/.ViewContactActivity }
D/AndroidRuntime( 1667): Shutting down VM
W/dalvikvm( 1667): threadid=1: thread exiting with uncaught exception (group=0x4001ac68)
E/AndroidRuntime( 1667): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 1667): java.lang.IllegalStateException: Couldn't find authenticator for specific account type
E/AndroidRuntime( 1667): at com.android.contacts.model.Sources.findAuthenticator(Sources.java:253)
E/AndroidRuntime( 1667): at com.android.contacts.model.Sources.queryAccounts(Sources.java:193)
E/AndroidRuntime( 1667): at com.android.contacts.model.Sources.<init>(Sources.java:109)
E/AndroidRuntime( 1667): at com.android.contacts.model.Sources.getInstance(Sources.java:93)
E/AndroidRuntime( 1667): at com.android.contacts.ViewContactActivity.buildEntries(ViewContactActivity.java:1372)
E/AndroidRuntime( 1667): at com.android.contacts.ViewContactActivity.bindData(ViewContactActivity.java:681)
E/AndroidRuntime( 1667): at com.android.contacts.ViewContactActivity.considerBindData(ViewContactActivity.java:674)
E/AndroidRuntime( 1667): at com.android.contacts.ViewContactActivity.onQueryComplete(ViewContactActivity.java:542)
E/AndroidRuntime( 1667): at com.android.contacts.util.NotifyingAsyncQueryHandler.onQueryComplete(NotifyingAsyncQueryHandler.java:65)
E/AndroidRuntime( 1667): at android.content.AsyncQueryHandler.handleMessage(AsyncQueryHandler.java:408)
E/AndroidRuntime( 1667): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1667): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1667): at android.app.ActivityThread.main(ActivityThread.java:4695)
E/AndroidRuntime( 1667): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1667): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1667): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
E/AndroidRuntime( 1667): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:663)
E/AndroidRuntime( 1667): at dalvik.system.NativeStart.main(Native Method)
I/Process ( 1017): Sending signal. PID: 1667 SIG: 3
I/dalvikvm( 1667): threadid=3: reacting to signal 3
It seems like it tries to find the authenticator but it does not find it... but why? Are there any limitations on the name / type of the authenticator for Android 2.1? Any ideas?
Turns out my sync-adapter was using a #string reference for the android:accountType attribute and for Android 2.1 it needs to be a hardcoded string, not the reference.
I have a test project which uses OI FileManager. I added that project to my test project as an Android library, then I call an Activitity in the library. It shows error:
E/AndroidRuntime( 1359): FATAL EXCEPTION: main
E/AndroidRuntime( 1359): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidcoretest/org.openintents.filemanager.FileManagerActivity}; have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime( 1359): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
E/AndroidRuntime( 1359): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
E/AndroidRuntime( 1359): at android.app.Activity.startActivityForResult(Activity.java:2817)
E/AndroidRuntime( 1359): at android.app.Activity.startActivity(Activity.java:2923)
E/AndroidRuntime( 1359): at com.androidcoretest.FileExplorerTest$1.onClick(FileExplorerTest.java:24)
E/AndroidRuntime( 1359): at android.view.View.performClick(View.java:2408)
E/AndroidRuntime( 1359): at android.view.View$PerformClick.run(View.java:8816)
E/AndroidRuntime( 1359): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 1359): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 1359): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1359): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 1359): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1359): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1359): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 1359): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 1359): at dalvik.system.NativeStart.main(Native Method)
When I add full path of that Activity in the Manifest, it generates another error.
<activity
android:label="#string/app_name"
android:name="org.openintents.filemanager.FileManagerActivity" >
</activity>
It shows:
E/AndroidRuntime( 1393): FATAL EXCEPTION: main
E/AndroidRuntime( 1393): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidcoretest/org.openintents.filemanager.FileManagerActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidcoretest/org.openintents.distribution.EulaActivity}; have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime( 1393): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
E/AndroidRuntime( 1393): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime( 1393): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime( 1393): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime( 1393): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1393): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1393): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 1393): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1393): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1393): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 1393): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 1393): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1393): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidcoretest/org.openintents.distribution.EulaActivity}; have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime( 1393): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
E/AndroidRuntime( 1393): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
E/AndroidRuntime( 1393): at android.app.Activity.startActivityForResult(Activity.java:2817)
E/AndroidRuntime( 1393): at android.app.Activity.startActivity(Activity.java:2923)
E/AndroidRuntime( 1393): at org.openintents.distribution.EulaOrNewVersion.startForwardActivity(EulaOrNewVersion.java:127)
E/AndroidRuntime( 1393): at org.openintents.distribution.EulaOrNewVersion.showEula(EulaOrNewVersion.java:69)
E/AndroidRuntime( 1393): at org.openintents.distribution.DistributionLibrary.showEulaOrNewVersion(DistributionLibrary.java:53)
E/AndroidRuntime( 1393): at org.openintents.filemanager.FileManagerActivity.onCreate(FileManagerActivity.java:312)
E/AndroidRuntime( 1393): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 1393): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime( 1393): ... 11 more
W/ActivityManager( 59): Force finishing activity com.androidcoretest/org.openintents.filemanager.FileManagerActivity
I would say this is a bug of Eclipse. Eclipse and ADT recently have many bugs on building process: ClassNotFound and ActivityNotFound.
Update:
My code just use one line:
final Intent intent = new Intent(FileExplorerTest.this, FileManagerActivity.class);
startActivity(intent);
Actually I have 3 projects. 2 library projects and 1 test project. Library "OI File Manager" uses Library "OI Distribution", then the test project C uses library "IO File Manager".
Ensure you are linking the OI FileManager projects as a library rather than external jar. go to Project properties > Android > Library, then click add library.
Then as you are doing define the activity in your project manifest (however with ADT 20 i think this is automatic)
<activity
android:label="#string/app_name"
android:name="org.openintents.filemanager.FileManagerActivity" >
</activity>
I guess it can't find com.androidcoretest/org.openintents.distribution.EulaActivity not the FileManager activity. Do you have that EulaActivity in the manifest?
See in your log:
Caused by: android.content.ActivityNotFoundException: Unable to find
explicit activity class
{com.androidcoretest/org.openintents.distribution.EulaActivity}; have
you declared this activity in your AndroidManifest.xml?
I have written for tables creation but when i am trying to access the table from one of my screen its throwing exception .
Even when i went do shell in commannd prompt i was not able to find that table . Any clue that i need to do .
logs :
W/System.err( 275): at java.lang.Thread.run(Thread.java:1096)
I/Database( 275): sqlite returned: error code = 1, msg = no such table: woman_registration
D/AndroidRuntime( 275): Shutting down VM
W/dalvikvm( 275): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime( 275): FATAL EXCEPTION: main
E/AndroidRuntime( 275): android.database.sqlite.SQLiteException: no such table: woman_registration: , while compiling: SELECT DISTINCT
* FROM woman_registration WHERE (m_name = ? AND f_name = ? and m_age_range = ?)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1229)
E/AndroidRuntime( 275): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1184)
E/AndroidRuntime( 275): at org.atl.db.DBAdapter.isWomanAlreadyRegisgtered(DBAdapter.java:376)
E/AndroidRuntime( 275): at com.accenturelabs.idoc.RegisterWoman.registerMother(RegisterWoman.java:237)
E/AndroidRuntime( 275): at com.accenturelabs.idoc.RegisterWoman.access$1(RegisterWoman.java:223)
E/AndroidRuntime( 275): at com.accenturelabs.idoc.RegisterWoman$4.onClick(RegisterWoman.java:141)
E/AndroidRuntime( 275): at android.view.View.performClick(View.java:2408)
E/AndroidRuntime( 275): at android.view.View$PerformClick.run(View.java:8816)
E/AndroidRuntime( 275): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 275): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 275): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 275): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 275): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 275): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 275): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 275): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 275): at dalvik.system.NativeStart.main(Native Method)
D/dalvikvm( 58): GC_FOR_MALLOC freed 18388 objects / 947880 bytes in 106ms
W/ActivityManager( 58): Force finishing activity com.accenturelabs.idoc/.RegisterWoman
I/ARMAssembler( 58): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x34d7b0:0x34d86c] in 7148901 ns
Try to chek from your ddms data -> data -> your package ->database
here you will find that table is created of not.
also it you pull it out and open with SQllite browser u will get all the table list in it.
Hope this will help you
You should be extending SQLiteOpenHelper for your database code if you are not already.
Then check that your onUpgrade() method also calls back to your onCreate() method. You may be dropping all your tables and then not re-creating them. Make sure you bump the database version number every time you make a change to your tables.
The google iosched app has a complete, if not slightly complex example of how to do this.
http://code.google.com/p/iosched/source/browse/android/src/com/google/android/apps/iosched/provider/ScheduleDatabase.java
Actually i had to uninstall the application from the emulator .it worked fine after that
My appwidget crashes with following error:
E/AndroidRuntime( 5572): FATAL EXCEPTION: main
E/AndroidRuntime( 5572): java.lang.RuntimeException: Unable to start receiver com.android.mlweatherwidget.WeatherWidgetLarge: java.lang.RuntimeException: system server dead?
E/AndroidRuntime( 5572): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1805)
E/AndroidRuntime( 5572): at android.app.ActivityThread.access$2400(ActivityThread.java:117)
E/AndroidRuntime( 5572): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
E/AndroidRuntime( 5572): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 5572): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 5572): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 5572): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 5572): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 5572): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 5572): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 5572): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 5572): Caused by: java.lang.RuntimeException: system server dead?
E/AndroidRuntime( 5572): at com.android.mlhome.appwidget.AppWidgetManager.getAppWidgetIds(AppWidgetManager.java:375)
E/AndroidRuntime( 5572): at com.android.mlweatherwidget.WeatherWidgetLarge.onReceive(WeatherWidgetLarge.java:202)
E/AndroidRuntime( 5572): at android.app.ActivityThread.handleReceiver(ActivityThread.java:1794)
E/AndroidRuntime( 5572): ... 10 more
E/AndroidRuntime( 5572): Caused by: android.os.DeadObjectException
E/AndroidRuntime( 5572): at android.os.BinderProxy.transact(Native Method)
E/AndroidRuntime( 5572): at com.android.mlhome.appwidget.ILauncherAppWidget$Stub$Proxy.getAppWidgetIds(ILauncherAppWidget.java:256)
E/AndroidRuntime( 5572): at com.android.mlhome.appwidget.AppWidgetManager.getAppWidgetIds(AppWidgetManager.java:369)
E/AndroidRuntime( 5572): ... 12 more
Can anybody understand from the above log what exactly is causing this error?
How to fix android.os.DeadObjectException android X
this guy met the same issue, check this link out.
I copyed the answer written by Dimitar Dimitrov as follows
This means that your service had already stopped - either killed from
the OS, or stopped from your application.
Does this problem happen every time you debug your project?
Override your service's onDestroy() method and watch what event flow
leads to it. If you catch DeadObjectException without going through
this method, your service should have been killed by the OS.
Started getting a ClassCastException in a widget I've been working on that I'm not sure what it's having an issue with. I haven't modified the configure class, nor the configure layout, yet I've started getting a stack trace leading back to my configure class after modifying the main layout
E/AndroidRuntime( 2010): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.metatroid.minimal.music/
com.metatroid.minimal.music.Configure}: java.lang.ClassCastException: android.widget.RadioButton
E/AndroidRuntime( 2010): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
E/AndroidRuntime( 2010): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime( 2010): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime( 2010): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime( 2010): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2010): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 2010): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 2010): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2010): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 2010): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 2010): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 2010): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 2010): Caused by: java.lang.ClassCastException: android.widget.RadioButton
E/AndroidRuntime( 2010): at com.metatroid.minimal.music.Configure.onCreate(Configure.java:39)
E/AndroidRuntime( 2010): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 2010): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime( 2010): ... 11 more
Reverting my changes causes the issue to go away, but I'm not doing anything with this file, nor am I modifying any RadioButtons...so what the hell? The line #39 of Configure.java is
EditText prv = (EditText) findViewById(R.id.previous_input);
I don't see how that ties into anything. And the only changes I am making to the entire project are changing some TextViews into Buttons in my main.xml layout which is not referenced in Configure.java. Reverting the Button back to TextView makes the error go away. What causes a "ClassCastException" and what could possibly be going on here?
Try clean your project. Previously you had RadioButton.