Deeplinking - app listed twice - android

I'm having an issue with deeplinking in my application. When I click a url from my email and it prompts me to choose an application to open the link with, my app is listed twice. One version works and the other does not. Any suggestions?
Here's the snippet of code I think could be the issue:
<application
android:name="com.test.TestApplication"
android:allowBackup="true"
android:fullBackupContent="#xml/backup_rules"
android:resizeableActivity="false"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="com.test.activity.LoginActivity"
android:configChanges="orientation"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />
<activity
android:name="com.test.activity.HomeActivity"
android:configChanges="orientation"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.MenuDrawer">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>

When an intent is sent to the system to open another activity, the system applies the rules specified here to find which activities/services can receive that intent. If there is more than one activity there, then the user will be prompted with all the matching activities. In this case what you experience is that the intent sent can be received (based on intent filters) by multiple activities, depending on how it is defined in your manifest.

Related

How to change default activity in Android app?

I used to use this apk a few months ago for studying and the last few days I've tried using it again but since I used it last time the app login system broke.
It used an login page for leaderboards and 1vs1 quizes but i dont need those features, i just need the learning environment.
But in order to get to the learning environment you have to log in, and since the log in doesn't work anymore I decided to take matters into my own hands and edit the app to bypass the login page, I've done my research and fell into a rabbit hole for 8 hours today and now i finally gave up.
This is part of the AndroidManifest.xml code:
<application android:allowBackup="true" android:appComponentFactory="androidx.core.app.CoreComponentFactory" android:icon="#mipmap/ic_app" android:label="#string/app_name" android:name="ro.umfquiz.umfquiz.presentation.UMFQuizApp" android:supportsRtl="true" android:theme="#style/AppTheme">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="#string/admob_app_id"/>
<activity android:name="ro.umfquiz.umfquiz.presentation.login.AuthenticationActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden|adjustPan"/>
<activity android:name="ro.umfquiz.umfquiz.presentation.login.FirstActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:name="ro.umfquiz.umfquiz.presentation.login.RegisterActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:name="ro.umfquiz.umfquiz.presentation.login.LoginActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:label="#string/app_name" android:name="ro.umfquiz.umfquiz.presentation.main.MainActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="ro.umfquiz.umfquiz.presentation.ModeSelectionActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize" android:label="#string/app_name" android:name="com.facebook.FacebookActivity" android:theme="#style/com_facebook_activity_theme"/>
<activity android:exported="true" android:name="com.facebook.CustomTabActivity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="#string/fb_login_protocol_scheme"/>
</intent-filter>
</activity>
<activity android:label="#string/training_mode" android:name="ro.umfquiz.umfquiz.presentation.testselection.training.TrainingSelectActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:label="#string/exam_mode" android:name="ro.umfquiz.umfquiz.presentation.testselection.exam.ExamSelectActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/>
<activity android:label="#string/title_activity_quiz" android:name="ro.umfquiz.umfquiz.presentation.quiz.types.exam.QuizExamActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden"/>
I used a 3rd party app to find what name does the login page have, and the name is "ro.umfquiz.umfquiz.presentation.login.AuthenticationActivity".
I learned that the activity with the intent-filter that has action.MAIN and category.LAUNCHER is the activity that launches by default, i have tried moving that intent-filter tag to MainActivity, then to ModeSelectionActivity, FirstActivity, etc and none of this worked, i still landed on the login page. After moving the intent tag i always recompiled signed and reinstalled the apk and also made sure the changes were saved.
I also tried using android:enabled="false" on a lot of activities related to login, that version failed to sign .. idk?
So please help me, i really need this app to work. here is the apk, you can check it for viruses if you dont trust me but i guarantee that is safe.
The tools i used were : apktool, MT Manager, apk-signer, Current Activity, Notepad ++.
Link to apk : Google Drive
TO change the default activity you just move the code that says
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
to the activity you want. Now whether the app will work after you do that- it depends on if it needed data from that login server, and if its coded defensively to not crash if it can't reach their servers. Most likely it will crash, either immediately or after some time when it attempts to access data it needed from the server. But you may be able to use some of the app without it, it depends on a lot of factors in how they code it and how the app works.
In AndroidManifest.xml file:
<activity android:name=".Your_Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Running android apps particular activity independently than rest of activities

THIS QUESTION IS SOLVED, PROVIDING ANSWER FOR FUTURE SO VISITORS BELOW
Context :
I am developing a default phone app. Which handles action.DIAL and action.CALL from My application as well as it handles these both intents from other apps too.
What is problem :
If my CallActivity is running ( if any call is ongoing ) then -
When i again try to open my app, it is presenting me CallActivity only.
And because of this i am unable to make another call by opening my app.
What manifest.xml looks like :
<application
android:allowBackup="true"
android:directBootAware="true"
android:fullBackupContent="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.CALL_BUTTON" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<activity
android:name=".CallActivity"
android:label="#string/title_activity_call"
android:process=":CallManager"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter android:priority="800">
<action android:name="android.intent.action.ACTION_CALL" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
</application>
What i found when searched for the said problem :
How can I launch an independent activity to my application as well as the application of phone launches the activity to make calls?
https://stackoverflow.com/questions/9458300/how-to-create-an-android-activity-and-service-that-use-separate-processes
What are my efforts taken :
You can note i tried android:process=":CallManager" attribute in manifest for my CallActivity
Did that solved the issue :
Nope. I am still unable to open my MainActivity, whenever CallActivity is running. But is caused the problem that now my call is not getting ended as this is completely another process it is unable to reference other calls which remain there in older process.
ANSWER
Did android:process was correct :
No not at all in this case, as it is used when our app memory usage increases over particular limit android starts caching its services and resources in order to avoid it developers generally use android:process which allows them another heap memory available with same heap size.
** What was problem :**
It was related to task and its affinities
Both activities needed to be separated for tasks and their affinities
like :
<activity
android:name="com.example.ActivityA"
android:label="Activity A"
android:launchMode="singleInstance"
android:taskAffinity="com.example.AffinityA" >
</activity>
<activity
android:name="com.example.ActivityB"
android:label="Activity B"
android:launchMode="singleInstance"
android:taskAffinity="com.example.AffinityB" >
</activity>
I must thanks #JayWozz for his answer over SO https://stackoverflow.com/a/45488126/9810130 and must appreciate #gabe-sechan for his sincere help and efforts and for giving his value-able time for this thread.
I think you're basically asking for a new stack of activities. Try launching the intent with FLAG_ACTIVITY_NEW_DOCUMENT| FLAG_ACTIVITY_MULTIPLE_TASKS That will launch the activity as if its a new set of activities, with its own separate listing in the recent apps list. See the definiton of these flags at https://developer.android.com/reference/android/content/Intent

React Native deeplinking and android:launchMode problem

I have been trying deeplinking in a react-native application and trying to directly open a screen inside a navigator. I use react-native-deep-linking and react-navigation as libraries. Also nested navigators are used. Deeplinking works correctly except I have some problems with the android:launchMode property.
This is the results I get for each of the android:launchMode options.
android:launchMode="standard" - App opens using the deeplink but opens up an entirely new application.
android:launchMode="singleTask" - App opens using the deeplink. If I open the app using another link. App comes to the foreground but it directs to the previous link.
android:launchMode="singleTop" - App opens using the deeplink but opens up an entirely new application.
android:launchMode="singleInstance" - App opens using the deeplink but opens up an entirely new application.
If I remove the android:launchMode property, again the same thing happens as the "standard" mode because it is the default.
What option can I use to resolve this problem? Is there any #override that I can do inside the main activity?
Below is my AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:launchMode="singleTask"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.VIEW"/>
<data android:scheme="https" android:host="*.myapplive.com" android:pathPrefix="/"/>
<data android:scheme="https" android:host="*.myapp.com" android:pathPrefix="/"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
</application>
Not sure if still relevant but may help someone in future.
The reason is that when activity is in any mode other than standard, re-opening the app from the background will not replace the original intent used to launch the app from the killed state. Instead, those new intents will be directed to the onNewIntent(Intent intent) method. There, you can call setIntent(Intent intent) in order to replace activity's intent with the new one.
You can override this method in your MainActivity. (Note that when overriding this method in React I had to make it public and not protected as I would usually do in Android. Not sure why yet)
Read more here - https://developer.android.com/reference/android/app/Activity#onNewIntent(android.content.Intent)

Android Deep linking and singleInstance/singleTask

Possible Duplicate Deep linking and multiple app instances. I have implemented Deep Linking in my app. I have Splash activity that is launcher and MainActivity that handles the Intent as defined in manifest:
<application
android:name=".MyApplication"
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="#drawable/app_logo"
android:label="#string/app_name"
android:largeHeap="true"
android:theme="#style/AppTheme">
<activity
android:name=".ActivitySplash"
android:configChanges="orientation|screenSize"
android:label="#string/app_name">
<intent-filter>
<!-- Launcher activity -->
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ActivityMain"
android:alwaysRetainTaskState="true"
android:configChanges="orientation|screenSize"
android:exported="true"
android:label="#string/app_name"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.mywebsite.com"
android:pathPrefix="/something"
android:scheme="http" />
</intent-filter>
</activity>
<activity
android:name=".ActivitySignIn"
android:configChanges="screenSize|orientation" />
<activity android:name=".ActivitySignUp" />
</application>
I have set launch mode singleTask to handle onNewIntent(). Now what i want to achieve is that if user opens activity from DeepLinking and there is already some task going on in MainActivity I prompt user a dialog either he want to cancel current task and start new task (which is from deep linking). The issue is If i open another activity from MainActivity and user comes from DeepLinking Intent. Then it would kill the second activity and directly open MainActivity. What i want to achieve is that if app/activity is not running then Intent from DeepLink open as is. And if activity/app is already running then i prompt user to either close current task and perform DeepLink task/intent.
This doesn't really work the way you think it does. You are trying to use launchMode="singleTask", but since you haven't also set "taskAffinity", Android pretty much ignores your launchMode.
You should not need to use either of the special launch modes "singleTask" or "singleInstance" to get what you want.
Try using singleTop launch mode and see if this solves your problem. If ActivityMain is already open and you launch ActivityMain again using your deep-link, onNewIntent() should be called in ActivityMain.
You can also look at my answer to this question which describes a way to determine what Activity to show based on using a static variable to decide whether another Activity is in the stack or not.

Application was returning to First Activity

I have an application that works like the UBER, it happens that when you're going on a run, the screen where the passenger accompanies the driver moving up to him, when the user will open other applications and attempt to return to the app by clicking on the main icon of the application that is in the launcher, the application returns to the first screen and not to the screen that was previously being screen is lost ...
My manifest.
<application
android:name=".Application"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:screenOrientation="portrait"
>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.RaceActivity" android:screenOrientation="portrait"></activity>
</application>
It is because you had used finish() in your java coding as i know if you use finish() for activity then it always finish your activity and when you will open app then it will start it from first screen .

Categories

Resources