Create second shortcuts in Launcher

I am creating a Cool app for Android home applications.

Since this is a home application, I do not want it to appear in Launcher in the list of all applications.

This is pretty easy, but now I would like the settings of this application to be displayed. So, I created my application preferences 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>

This works very well and I have an extra icon in Launcher!

The only problem is that nothing happens when I click on the icon. Therefore, I can run my settings from 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 completely useless and doesn't launch anything?

Further information here:

The log when starting from the application (the settings start, work flawlessly):

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

( ):

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 }

:

public class Preferences extends PreferenceActivity {

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

 }
}
+3
1

- ! ( , , ? ?)

:

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

!

+1

Source: https://habr.com/ru/post/1761490/


All Articles