gpt4 book ai didi

android - FragmentActivity 在 onStart 中崩溃

转载 作者:行者123 更新时间:2023-11-30 03:36:02 25 4
gpt4 key购买 nike

出于某种原因,我的应用程序在 super.onCreate 中崩溃并出现 nullPointerException。它是一个扩展了 fragmentActivity 的 Activity 。

public class LiveMatchActivity extends FragmentActivity

那是我的 onStart():

@Override
protected void onStart() {
super.onStart();
Analytics.getIntance().trackStart(this);
}

当我到达 super.onStart() 时,应用崩溃了。

这是日志:

    05-20 11:22:42.735: E/Crittercism(29328): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ftbpro.app/com.ftbpro.app.LiveMatchActivity}: java.lang.NullPointerException
05-20 11:22:42.735: E/Crittercism(29328): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
05-20 11:22:42.735: E/Crittercism(29328): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
05-20 11:22:42.735: E/Crittercism(29328): at android.app.ActivityThread.access$600(ActivityThread.java:140)
05-20 11:22:42.735: E/Crittercism(29328): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
05-20 11:22:42.735: E/Crittercism(29328): at android.os.Handler.dispatchMessage(Handler.java:99)
05-20 11:22:42.735: E/Crittercism(29328): at android.os.Looper.loop(Looper.java:137)
05-20 11:22:42.735: E/Crittercism(29328): at android.app.ActivityThread.main(ActivityThread.java:4898)
05-20 11:22:42.735: E/Crittercism(29328): at java.lang.reflect.Method.invokeNative(Native Method)
05-20 11:22:42.735: E/Crittercism(29328): at java.lang.reflect.Method.invoke(Method.java:511)
05-20 11:22:42.735: E/Crittercism(29328): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
05-20 11:22:42.735: E/Crittercism(29328): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
05-20 11:22:42.735: E/Crittercism(29328): at dalvik.system.NativeStart.main(Native Method)
05-20 11:22:42.735: E/Crittercism(29328): Caused by: java.lang.NullPointerException
05-20 11:22:42.735: E/Crittercism(29328): at com.ftbpro.app.EventsFragment.filterAndSortEventsList(EventsFragment.java:211)
05-20 11:22:42.735: E/Crittercism(29328): at com.ftbpro.app.EventsFragment.onCreateView(EventsFragment.java:57)
05-20 11:22:42.735: E/Crittercism(29328): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
05-20 11:22:42.735: E/Crittercism(29328): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
05-20 11:22:42.735: E/Crittercism(29328): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
05-20 11:22:42.735: E/Crittercism(29328): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1070)
05-20 11:22:42.735: E/Crittercism(29328): at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1861)
05-20 11:22:42.735: E/Crittercism(29328): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547)
05-20 11:22:42.735: E/Crittercism(29328): at com.ftbpro.app.LiveMatchActivity.onStart(LiveMatchActivity.java:77)
05-20 11:22:42.735: E/Crittercism(29328): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1178)
05-20 11:22:42.735: E/Crittercism(29328): at android.app.Activity.performStart(Activity.java:5216)
05-20 11:22:42.735: E/Crittercism(29328): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2073)
05-20 11:22:42.735: E/Crittercism(29328): ... 11 more

private void filterAndSortEventsList(LiveMatchDetails liveMatchDetailsToSort) {
List<Event> eventsList = new ArrayList<Event>();
Event gameStartedEvent = null;
Event gameEndedEvent = null;
for (Event event : liveMatchDetailsToSort.getEventsList()) {
if (event.getEvent().equals(Event.YELOW_CARD)
|| event.getEvent().equals(Event.YELOW_CARD2)
|| event.getEvent().contains(Event.GOAL)
|| event.getEvent().equals(Event.RED_CARD)) {
eventsList.add(event);
}
if (event.getExtObjType().equals(GAME_STARTED_OR_ENDED)) {
if (event.getMinute() == 0) {
gameStartedEvent = event;
} else if (event.getMinute() == 90) {
gameEndedEvent = event;
}
}
}
Collections.sort(eventsList);
if (gameEndedEvent != null) {
eventsList.add(0, gameEndedEvent);
}
eventsList.add(gameStartedEvent);
liveMatchDetailsToSort.setEventsList(eventsList);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.events_fragments, container,
false);
TypefaceManager.getInstance(getActivity())
.assignTypeface(getActivity());
events = ((LiveMatchActivity) getActivity()).getEvents();

filterAndSortEventsList(events);
ListView eventsListView = (ListView) view
.findViewById(R.id.live_match_list);
eventsListView.setAdapter(new LiveEventsAdapter());

return view;
}

它会是什么?

最佳答案

它没有在 super.onStart() 上崩溃这里有问题

at com.ftbpro.app.EventsFragment.filterAndSortEventsList(EventsFragment.java:211)

如果您可以粘贴 EventsFragment.java 文件的代码,我们可以尝试以更好的方式帮助您。

关于android - FragmentActivity 在 onStart 中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16645458/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com