各位大哥:小弟对android 问题追踪调试不是很懂,最近系统出现一个Bug,日历弹出一个错误 在Android系统上, :
java.lang.NullPointerException:
at com.android.providers.calendar.CalendarSyncAdapter.onAccountsChanged(CalendarSyncAdapter.java:1400)
at android.content.AbstractSyncableContentProvider$1.onAccountsUpdated(AbstractSyncableContentProvider.java:187)
at android.accounts.AccountManager$10.run(AccountManager.java:826)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4325)
at java.lang.reflect.Method.invokeNative(Method.java:-2)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
追踪代码到1400 行
public void onAccountsChanged(Account[] accountsArray) {
if (!"yes".equals(SystemProperties.get("ro.config.sync"))) {
return;
} // - Get a cursor (A) over all sync'd calendars over all accounts
// - Get a cursor (B) over all subscribed feeds for calendar
// - If an item is in A but not B then add a subscription
// - If an item is in B but not A then remove the subscription ContentResolver cr = getContext().getContentResolver();
Cursor cursorA = null;
Cursor cursorB = null;
try {
cursorA = Calendar.Calendars.query(cr, null /* projection */,
Calendar.Calendars.SYNC_EVENTS + "=1", CALENDAR_KEY_SORT_ORDER);
int urlIndexA = cursorA.getColumnIndexOrThrow(Calendar.Calendars.URL);
int accountNameIndexA = cursorA.getColumnIndexOrThrow(Calendar.Calendars._SYNC_ACCOUNT);
int accountTypeIndexA =
cursorA.getColumnIndexOrThrow(Calendar.Calendars._SYNC_ACCOUNT_TYPE);
cursorB = SubscribedFeeds.Feeds.query(cr, FEEDS_KEY_COLUMNS,
SubscribedFeeds.Feeds.AUTHORITY + "=?", new String[]{Calendar.AUTHORITY},
FEEDS_KEY_SORT_ORDER); int urlIndexB = cursorB.getColumnIndexOrThrow(SubscribedFeeds.Feeds.FEED);
int accountNameIndexB =
cursorB.getColumnIndexOrThrow(SubscribedFeeds.Feeds._SYNC_ACCOUNT);
int accountTypeIndexB =
cursorB.getColumnIndexOrThrow(SubscribedFeeds.Feeds._SYNC_ACCOUNT_TYPE);
for (CursorJoiner.Result joinerResult :
new CursorJoiner(cursorA, CALENDAR_KEY_COLUMNS, cursorB, FEEDS_KEY_COLUMNS)) {
switch (joinerResult) {
case LEFT:
SubscribedFeeds.addFeed(
cr,
cursorA.getString(urlIndexA),
new Account(cursorA.getString(accountNameIndexA),
cursorA.getString(accountTypeIndexA)),
Calendar.AUTHORITY,
CalendarClient.SERVICE);
break;
case RIGHT:
SubscribedFeeds.deleteFeed(
cr,
cursorB.getString(urlIndexB),
new Account(cursorB.getString(accountNameIndexB),
cursorB.getString(accountTypeIndexB)),
Calendar.AUTHORITY);
break;
case BOTH:
// do nothing, since the subscription already exists
break;
}
}
} finally {
// check for null in case an exception occurred before the cursors got created
if (cursorA != null) cursorA.close();
if (cursorB != null) cursorB.close();
}
}
cursor B 空指针 然后不知道如何跟踪下去了,求高手指点这种问题如何跟踪
java.lang.NullPointerException:
at com.android.providers.calendar.CalendarSyncAdapter.onAccountsChanged(CalendarSyncAdapter.java:1400)
at android.content.AbstractSyncableContentProvider$1.onAccountsUpdated(AbstractSyncableContentProvider.java:187)
at android.accounts.AccountManager$10.run(AccountManager.java:826)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4325)
at java.lang.reflect.Method.invokeNative(Method.java:-2)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
追踪代码到1400 行
public void onAccountsChanged(Account[] accountsArray) {
if (!"yes".equals(SystemProperties.get("ro.config.sync"))) {
return;
} // - Get a cursor (A) over all sync'd calendars over all accounts
// - Get a cursor (B) over all subscribed feeds for calendar
// - If an item is in A but not B then add a subscription
// - If an item is in B but not A then remove the subscription ContentResolver cr = getContext().getContentResolver();
Cursor cursorA = null;
Cursor cursorB = null;
try {
cursorA = Calendar.Calendars.query(cr, null /* projection */,
Calendar.Calendars.SYNC_EVENTS + "=1", CALENDAR_KEY_SORT_ORDER);
int urlIndexA = cursorA.getColumnIndexOrThrow(Calendar.Calendars.URL);
int accountNameIndexA = cursorA.getColumnIndexOrThrow(Calendar.Calendars._SYNC_ACCOUNT);
int accountTypeIndexA =
cursorA.getColumnIndexOrThrow(Calendar.Calendars._SYNC_ACCOUNT_TYPE);
cursorB = SubscribedFeeds.Feeds.query(cr, FEEDS_KEY_COLUMNS,
SubscribedFeeds.Feeds.AUTHORITY + "=?", new String[]{Calendar.AUTHORITY},
FEEDS_KEY_SORT_ORDER); int urlIndexB = cursorB.getColumnIndexOrThrow(SubscribedFeeds.Feeds.FEED);
int accountNameIndexB =
cursorB.getColumnIndexOrThrow(SubscribedFeeds.Feeds._SYNC_ACCOUNT);
int accountTypeIndexB =
cursorB.getColumnIndexOrThrow(SubscribedFeeds.Feeds._SYNC_ACCOUNT_TYPE);
for (CursorJoiner.Result joinerResult :
new CursorJoiner(cursorA, CALENDAR_KEY_COLUMNS, cursorB, FEEDS_KEY_COLUMNS)) {
switch (joinerResult) {
case LEFT:
SubscribedFeeds.addFeed(
cr,
cursorA.getString(urlIndexA),
new Account(cursorA.getString(accountNameIndexA),
cursorA.getString(accountTypeIndexA)),
Calendar.AUTHORITY,
CalendarClient.SERVICE);
break;
case RIGHT:
SubscribedFeeds.deleteFeed(
cr,
cursorB.getString(urlIndexB),
new Account(cursorB.getString(accountNameIndexB),
cursorB.getString(accountTypeIndexB)),
Calendar.AUTHORITY);
break;
case BOTH:
// do nothing, since the subscription already exists
break;
}
}
} finally {
// check for null in case an exception occurred before the cursors got created
if (cursorA != null) cursorA.close();
if (cursorB != null) cursorB.close();
}
}
cursor B 空指针 然后不知道如何跟踪下去了,求高手指点这种问题如何跟踪
解决方案 »
- TextView字符串没超出长度后面为什么总是显示省略号?
- 请教screenOrientation="nosensor"和configChanges="keyboardHidden|ori
- 安卓的这个控件是什么
- android游戏启动动画返回问题
- Android新手 下载安装 失败
- listview的getview方法为什么会调用三次啊??
- Android2.2 不支持setRotation和getRotation方法
- Android界面中button按钮的文字不居中,求大神指导。
- 内存被自动释放了
- datepickerdialog
- android调用C#编写的WebService
- 关于android3.0停止/暂停开源
这个是google账户同步的代码和日历本身使用不大