How do I get multiple icons to launch different activities in one application?
What you need to do is have your settings activity launch in another task. You can do this by specifying its task affinity. This is done with the attribute android:taskAffinity
. By default all activities share the same task affinity that defaults to main package specified in the manifest. On your settings activity you can specify android:taskAffinity="your.own.package.SettingsTask"
to have the settings activity launch in its own task.
Extra documentation.
How to open main activity from two separate icons with different ui
First you need to add second launcher intent to your manifest.
<activity
android:name=".yourpackage.MapActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="visibility" android:value="0"/>
</activity>
<activity-alias
android:name=".MapWithoutFabActivity"
android:targetActivity=".yourpackage.MapActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="visibility" android:value="1"/>
</activity-alias>
Next we need modify our map MapActivity for being ready to change visibility of fab button.
public class MapActivity extends AppCompatActivity {
protected int fabVisibility = View.VISIBLE;
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Hope this method works.
Bundle bundle = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA).metaData;
int visibility = Integer.valueOf(bundle.getString("visibility"));
fab.setVisibility(visibility);
}
protected void onNewIntent(Intent intent) {
Bundle bundle = getPackageManager().getApplicationInfo(getPackageName(),
PackageManager.GET_META_DATA).metaData;
int visibility = Integer.valueOf(bundle.getString("visibility"));
fab.setVisibility(visibility);
}
Good luck there
Emre
How to assign visually different launch icons for different Android activities
In each activity
element of your manifest add the android:icon
attribute and assign it to a drawable. For example <activity ... android:icon="@drawable/icon_x"
.
Two launcher activities
You need to specify which activity is the default one by adding the following line to your intent-filter:
<category android:name="android.intent.category.DEFAULT"/>
Insert this in the default activity and keep the rest. Then it should work.
You may also want to add a different icon to your 2nd activity with the attribute android:icon="@drawable/myothericon"
Android App activities installed as multiple icons
Your manifest file should only have this line in the activity you want to have an icon:
<category android:name="android.intent.category.MAIN" />
Based on your description, it sounds like both activities have this line.
Android application suite with multiple launcher icons does resumes to same activity no matter which was selected
You'll have to set the activities with different task affinities. See the Application Fundamentals section from the Android docs.
Related Topics
Apk Location in New Android Studio
Android Webview Inside Scrollview Scrolls Only Scrollview
How to Get Retrofit Success Response Status Codes
Gcm Service_Not_Available on Android 2.2
Copy Database from Assets to Databases Folder
How to Add Action Bar from Support Library into Preferenceactivity
Android: Collapsingtoolbarlayout and Swiperefreshlayout Get Stuck
Android L's Ripple Effect - Touch Feedback for Buttons - Using Xml
Android Mask Bitmap on Canvas Gen a Black Space
Android Edittext Onchange Listener
Android Update Textview in Thread and Runnable
Android:Fill Spinner from Java Code Programmatically
Android Toggle Button Custom Look
Sharing a Png Image in Drawable Folder
Firebase Admin Sdk for Android, Methods Not Found
How to Start Power Manager of All Android Manufactures to Enable Background and Push Notification
Creating Viewholders for Listviews with Different Item Layouts