Beginning an application while no starting activity set

I would like to launch my application and check the connectivity state in application's onCreate method then decide which activity to start! I know that I could finish() a default MAIN/LAUNCHER activity before to setLayout while starting another if it's relevant but that seems messy to me!

So, I would like to know if it is possible to start an application whose doesn't manifest an activity with action.MAIN / category.LAUNCHER? I tried this way but it doesn't work! I mean the application seems to start but no activity is shown!

(This is not a sample from my real code, I'm not at home right now! Some arguments and stuff may be missing but I think you get the point!)

public class MyApp extends Application {
    onCreate() {
        Intent intent = new Intent(this, MyActivity.class);

Also, the first activity of my application may be an AlertDialog and I'm wondering if I can start one while no activity is started or if I'm forced to set an activity's theme with @android:style/Theme.Dialog?

I tried the same as for the above example but same result : logcat saying application alive while no printing at all...

Tell me if I'm not clear enough and in which way! I'm not an english speaker and I'm not used to ask in forums!


You will have to go this way:

public class MainActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.some_empty_or_loading_view); //optional probably, not sure

        //TODO: check whatever you want
        if(condition) {
            startActivity(this, SomeActivity.class);
        } else {
            startActivity(this, AnotherActivity.class);


Specify Your App's Launcher Activity

When the user selects your app icon from the Home screen, the system calls the onCreate() method for the Activity in your app that you've declared to be the "launcher" (or "main") activity. This is the activity that serves as the main entry point to your app's user interface.

You can define which activity to use as the main activity in the Android manifest file, AndroidManifest.xml, which is at the root of your project directory.

The main activity for your app must be declared in the manifest with an that includes the MAIN action and LAUNCHER category. For example:

<activity android:name=".MainActivity" android:label="@string/app_name">
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />

Note: When you create a new Android project with the Android SDK tools, the default project files include an Activity class that's declared in the manifest with this filter.

If either the MAIN action or LAUNCHER category are not declared for one of your activities, then your app icon will not appear in the Home screen's list of app

Need Your Help

Can I read the track number of a song from OneDrive using the LiveConnect API?

c# .net windows-phone-8 onedrive liveconnect

The REST API provides the title, artist, album, and picture for each track. However, I don't see any way to retrieve the track number.