开发者

onCreate() isn't being called

I just got a very strange problem which I have now spendt hours trying to solve. When I try to run my android app (both on my phone and in the emulator) I get nothing. The activity label from the AndroidManifest file (android:label="@string/list_name") is set correctly, but otherwise I just have a blink screen.

I inserted a breakpoint together with 30 Log.d()'s right after the super() in my onCreate() method, but the breakpoint is never reached, and the Log.d()'s are never printed. Also, I do not get any exceptions in logcat.

The app worked before, and I have no idea how the it can be that the breakpoint never is reache开发者_如何学运维d.

PS: It is my main activity

PS2: I've cleaned the project, rebuilt it, rebooted. The problem didn't disappear :(

PS3: My onCreate() is quite long, but this is how it starts:

@Override
public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.episode);
        Log.d("Very Strange", "This is never printed");
        Log.d("Very Strange", "This is never printed");
        // no breakpoints is every reached

My manifest file can be found here: http://pastebin.com/UcKbYeGC


Try this:

 public void onCreate(Bundle savedInstanceState)
 {
    Log.d("Very Strange", "Printed #1?");
    super.onCreate(savedInstanceState);
    Log.d("Very Strange", "Printed #2?");
    setContentView(R.layout.episode);
    Log.d("Very Strange", "This is never printed");
    Log.d("Very Strange", "This is never printed");

Just an offtopic tip: use a control version system to ensure you can rollback or compare the working one with the current


The call of super() is not correct, as it just calls the empty constructor of the Activity class. You need to call the static method super.onCreate() in order to generate the Activity correctly.


Your activity myListView is the activity that's started on application start. Is this correct? Else, have a look at your manifest and specify the correct intent filter for your episodes activity (simply cut/paste it from the MyListView entry in your manifest)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜