Launch view using different app launchers with two icons

I have designed an app using ionic 3 /cordova for android. I want multiple launchers that show different views of the ionic app. I have created launchers using AndroidManifest.xml and creating two activities

I have two icons which is what I want. Problem is, how to I get the second icon to launch the specific view I want in a separate instance of the same app? Thanks!

What does that mean? A launcher normally is the app running the homescreen on Android, isn’t it?

How?

I want after installation of my application that two icons are created on the user’s phone menu each of these icons open to a module of the application

You said so before.

But I asked another question.

Yes that’s exactly it

Then your question doesn’t make sense. One can only run one launcher at a time on Android.

Please look page https://stackoverflow.com/questions/15526805/two-main-activities-in-androidmanifest-xml And https://derekreynolds.wordpress.com/2012/06/09/how-to-have-multiple-launcher-icons-in-one-android-apk-install-for-different-activities/

Sorry for my English I am francophone , I know how to do this so I’m talking to you about android studio may have found that when I generate an application on ionic cordova I only have one activity and those so I want is how can I specify another activity in my config.xml file.Please understand my problem?

Can you share your AndroidManifest.xml?

I think you will have to somehow find out which one of the icons was clicked and use that information to redirect to another screen.

AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0" package="com.bodybeautiful.app" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="de.appplant.cordova.emailcomposer.EmailComposerProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/emailcomposer_provider_paths" />
        </provider>
        <provider android:authorities="${applicationId}.sharing.provider" android:exported="false" android:grantUriPermissions="true" android:name="nl.xservices.plugins.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/sharing_paths" />
        </provider>
        <amazon:enable-feature android:name="com.amazon.device.messaging" android:required="false" xmlns:amazon="http://schemas.amazon.com/apk/res/android" />
        <service android:exported="false" android:name="com.onesignal.ADMMessageHandler" />
        <receiver android:name="com.onesignal.ADMMessageHandler$Receiver" android:permission="com.amazon.device.messaging.permission.SEND">
            <intent-filter>
                <action android:name="com.amazon.device.messaging.intent.REGISTRATION" />
                <action android:name="com.amazon.device.messaging.intent.RECEIVE" />
                <category android:name="com.bodybeautiful.app" />
            </intent-filter>
        </receiver>
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id" />
        <meta-data android:name="com.facebook.sdk.ApplicationName" android:value="@string/fb_app_name" />
        <activity android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/fb_app_name" android:name="com.facebook.FacebookActivity" />
        <provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="android.support.v4.content.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" />
        </provider>
        <provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="de.appplant.cordova.plugin.notification.util.AssetProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/localnotification_provider_paths" />
        </provider>
        <receiver android:exported="false" android:name="de.appplant.cordova.plugin.localnotification.TriggerReceiver" />
        <receiver android:exported="false" android:name="de.appplant.cordova.plugin.localnotification.ClearReceiver" />
        <activity android:exported="false" android:launchMode="singleInstance" android:name="de.appplant.cordova.plugin.localnotification.ClickReceiver" android:theme="@android:style/Theme.Translucent" />
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.amazon.device.messaging.permission.RECEIVE" />
    <permission android:name="com.bodybeautiful.app.permission.RECEIVE_ADM_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.bodybeautiful.app.permission.RECEIVE_ADM_MESSAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>

Can you highlight the code responsible for adding the two launcher icons?

Hello my friends the code that I use on Android studio for such architecture is:

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

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="27" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <application
        android:name="com.projet.collecte.demo.database.InitDb"
        android:allowBackup="true"
        android:debuggable="true"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name="com.projet.collecte.demo.activities.Lancement"
            android:icon="@mipmap/ic_launcher2">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.projet.collecte.demo.activities.Connexion" />
        <activity
            android:name="com.projet.collecte.demo.MainActivity"
            android:icon="@mipmap/ic_launcher2"
            android:label="@string/title_activity_main"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

Why is this a different project? Where from was the AndroidManifest.xml you posted before?

Ok, so you are launching two different activities.
Does this work in an Ionic app? What exactly does it show?

For your idea to work, I think you would have to find out if the app was opened to com.projet.collecte.demo.activities.Lancement or com.projet.collecte.demo.MainActivity.

In fact my ionic only generates a main file that has the following code,

public class MainActivity extends CordovaActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        // enable Cordova apps to be started in the background
        Bundle extras = getIntent().getExtras();
        if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
            moveTaskToBack(true);
        }

        // Set by <content src="index.html" /> in config.xml
        loadUrl(launchUrl);
    }
}

but my project is made up of two modules and I would like to have a manifesto that is eligible for the second AndroidManifest.xml

I would like to create an activity that opens a specific page in my project. Thanks again for your good understanding

Ok, so the AndroidManifest with 2 activities is not from your Ionic project?

Yes that’s precisely my problem

Manually you could duplicate the MainActivity to SecondActivity, then add something to the end of launchUrl. Also manually edit your AndroidManifest.xml so you have the second icon for that SecondActivity. Then find a way to read the param that you added to launchUrl in your app - probably easiest by adding some plain JS into your index.html and setting a global JS variable you can then read in your TS code.

thanks a lot for your help. I try your procedure

Thank you very much I found this link and I think it will help me https://github.com/EddyVerbruggen/Custom-URL-scheme

This doesn’t really sound related in any way to your goal. This is for opening an app via a link from a website or other apps, not from the Apps list or Homescreen.