views:

45

answers:

1

Hello, I create a cool Home application in Android.

As this is a Home I don't want her to appear in the Launcher, in the list of all applications.

That's pretty easy, but now I would like the settings of this application to appear. So, I created the preferences of my application this way in the Manifest:

   <activity android:name=".Preferences" android:label="@string/application_name">
   <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>

That work pretty well and I have an extra icon in the Launcher!

The only problem is that nothing happen when I click on the Icon.

Therefore, I can launch my Preferences from within the application:

    final Intent preferences = new Intent(Launcher.this,Preferences.class);        
    menu.add(0, MENU_PREFERENCES, 0, R.string.application_name).setIcon(
            R.drawable.ic_menu_preferences).setAlphabeticShortcut('F').setIntent(
              preferences);

So why is the shortcut in the launcher totally useless and does not launch anything???

More informations here:

Log when I launch from within the application: (PREFERENCES ARE LAUNCHED, WORKED FLAWLESSLY)

    08-25 13:13:03.009: INFO/ActivityManager(63): Starting activity: Intent { cmp=com.myapp.home/.Preferences }

When I launch from the launcher: (NOTHINHG HAPPEN)

    08-25 13:13:45.489: INFO/ActivityManager(63): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.myapp.home/.Preferences }

My activity:

    public class Preferences extends PreferenceActivity {

     @Override
     protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      addPreferencesFromResource(R.xml.preferences);

     }
    }

Thank a lot for any help.

+1  A: 

Just found something! (And btw, what is the best procedure to use when I found an answer to my own question? Should I answer myself? here..)

I had to use that in Manifest:

      <activity android:clearTaskOnLaunch="true" android:launchMode="singleTask" android:stateNotNeeded="true" (...other parameters...)>

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

That work pretty well!

Profete162
Answering yourself is fine
Falmarri