简体   繁体   中英

Android Programming Not Showing up in Emulator, Read other questions, still no solution

For my Android App, I've declared multiple Activities in the AndroidManifest.xml file.

The AndroidManifest.xml file is

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.btdt"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="10" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/quizicon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" android:debuggable="true">

        <activity android:name="QuizActivity"

            android:label="@string/app_name" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>

        <activity android:name="QuizSplashActivity"> </activity>
        <activity android:name="QuizGameActivity"> </activity>
        <activity android:name="QuizHelpActivity"> </activity>
        <activity android:name="QuizMenuActivity"> </activity>
        <activity android:name="QuizScoresActivity"> </activity>
        <activity android:name="QuizSettingsActivity"> </activity>

    </application>

</manifest>

For some reason, my App never shows up on the Emulator. I've read the answers of other people asking the same question, but my App still does not show. I do not get any Compilation or Running Errors.

If it's any help, my QuizActivity.java file is

package com.example.btdt;

import android.os.Bundle;
import android.app.Activity;
import android.content.SharedPreferences;
import android.view.Menu;
import android.widget.TextView;

public class QuizActivity extends Activity {
    TextView countDisplay;

    public static final String GAME_PREFERENCES = "GamePrefs";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_quiz_splash);

        SharedPreferences settings =
                getSharedPreferences(GAME_PREFERENCES, MODE_PRIVATE);
        SharedPreferences.Editor prefEditor = settings.edit();
        prefEditor.putString("UserName", "Ryan D'souza");
        prefEditor.putInt("UserAge", 16);
        prefEditor.commit();

        countDisplay = new TextView(this);
        this.setContentView(countDisplay);

        if(settings.contains("UserName") == true)
        {
            String user = settings.getString("UserName", "Default");
            countDisplay.setText(user);

        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.quiz_splash, menu);
        return true;
    }

}

Thank you for your help

Try To declare your other activities like that:

    <activity
        android:name=".YourClass"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.your.package.name" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

If the emulator does not show it, restart Eclipse and open it. Before to run the app, open the emulator and wait still it load.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM