1

出于某种原因,我的应用程序在super.onCreate. 它是一个扩展 fragmentActivity 的活动。

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;
}

会是什么呢?

4

1 回答 1

1

它不会在 super.onStart() 上崩溃,这里有问题

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

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

于 2013-05-20T08:59:16.940 回答