Android activity from background restore is incorrect - android

I have the following flow in my application:
SignInActivity (MAIN) -> Android Browser (for OAuth) -> OAuth Activity ->
-> PinCode Activity -> SignInActivity -> AccountActivity
Flag NoHistory = True for all activities.
In my testing, I see that when I am at the AccountActivity and I send the app to background (by clicking on the home button), the app resumes back with the OAuth Activity. This is incredibly disturbing because the OAuth flow finishes right after the PinCode flow is triggered. Like:
try
{
Server.FinalOAuthChallenge(...) // blocking API
...
GoToPinCodeSetupActivity();
Intent startPinFlow = new Intent(this, typeof(PinCodeActivity));
startPinFlow.PutExtra(SKConstants.SKPinCodeIntentArgumentIsStartKey, true);
startPinFlow.PutExtra(SKConstants.SKPinCodeIntentArgumentTypeKey, (int)PinCodeActivity.Type.Set);
StartActivity(startPinFlow);
Finish();
}
Every time the application starts from the background, it actually starts this OAuth Activity. It's also weird because I have already set the NoHistory flag to true.
Here's how I create my browser intent:
Intent oauthIntent = new Intent(Intent.ActionView, uri);
oauthIntent.AddFlags(ActivityFlags.ClearTask);
oauthIntent.AddFlags(ActivityFlags.NewTask);
activity.StartActivity(oauthIntent);
Here's my AndroidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.alpha.romeo" android:versionName="1.1.3" android:versionCode="9">
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="19" />
<application android:name="AlphaRomeo.SKApplication" android:label="AlphaRomeo" android:icon="#drawable/icon">
<activity android:label="#string/appName" android:name="AlphaRomeo.SignInActivity" android:screenOrientation="portrait" android:configChanges="orientation" android:noHistory="true">
<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.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</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" />
<data android:scheme="http" />
<data android:host="*" />
<data android:pathPattern=".*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\..*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ALPHAROMEO" />
<data android:mimeType="*/*" />
</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" />
<data android:scheme="https" />
<data android:host="*" />
<data android:pathPattern=".*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\..*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ALPHAROMEO" />
<data android:mimeType="*/*" />
</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" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\..*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ALPHAROMEO" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ALPHAROMEO" />
<data android:mimeType="*/*" />
</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" />
<data android:scheme="content" />
<data android:mimeType="application/octet-stream" />
</intent-filter>
</activity>
<activity android:name="AlphaRomeo.OAuthActivity" android:label="#string/appName">
<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="com.alpha.romeo" android:host="oauth" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
</manifest>

Related

android:exported be defined when intent filters are present

I am a beginner in programming and I am trying to understand more
I downloaded an open source app and am trying to make some modifications as a form of training
But when I set minsdk 31
The app no ​​longer works I checked after the lessons and instructions
I have to edit the mainfest file
I made some changes but I don't know if they are enough
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.schabi.newpipe"
android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.software.leanback"
android:required="false" />
<application
android:name=".App"
android:allowBackup="true"
android:banner="#mipmap/newpipe_tv_banner"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:logo="#mipmap/ic_launcher"
android:theme="#style/OpeningTheme"
android:resizeableActivity="true"
tools:ignore="AllowBackup">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="androidx.media.session.MediaButtonReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
<service
android:name=".player.PlayerService"
android:exported="false"
android:foregroundServiceType="mediaPlayback">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</service>
<activity
android:name=".player.PlayQueueActivity"
android:label="#string/title_activity_play_queue"
android:launchMode="singleTask" />
<activity
android:name=".settings.SettingsActivity"
android:label="#string/settings" />
<activity
android:name=".about.AboutActivity"
android:label="#string/title_activity_about" />
<service android:name=".local.subscription.services.SubscriptionsImportService" />
<service android:name=".local.subscription.services.SubscriptionsExportService" />
<service android:name=".local.feed.service.FeedLoadService" />
<activity
android:name=".PanicResponderActivity"
android:launchMode="singleInstance"
android:noHistory="true"
android:theme="#android:style/Theme.NoDisplay"
android:exported="true">
<intent-filter>
<action android:name="info.guardianproject.panic.action.TRIGGER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".ExitActivity"
android:label="#string/general_error"
android:theme="#android:style/Theme.NoDisplay" />
<activity android:name=".error.ErrorActivity" />
<!-- giga get related -->
<activity
android:name=".download.DownloadActivity"
android:label="#string/app_name"
android:launchMode="singleTask" />
<service android:name="us.shandian.giga.service.DownloadManagerService" />
<activity
android:name=".util.FilePickerActivityHelper"
android:label="#string/app_name"
android:theme="#style/FilePickerThemeDark"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".error.ReCaptchaActivity"
android:label="#string/recaptcha" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/nnf_provider_paths" />
</provider>
<activity
android:name=".RouterActivity"
android:excludeFromRecents="true"
android:label="#string/preferred_open_action_share_menu_title"
android:taskAffinity=""
android:theme="#style/RouterActivityThemeDark"
android:exported="true">
<!-- Youtube filter -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="youtube.com" />
<data android:host="m.youtube.com" />
<data android:host="www.youtube.com" />
<data android:host="music.youtube.com" />
<!-- video prefix -->
<data android:pathPrefix="/v/" />
<data android:pathPrefix="/embed/" />
<data android:pathPrefix="/watch" />
<data android:pathPrefix="/attribution_link" />
<data android:pathPrefix="/shorts/" />
<!-- channel prefix -->
<data android:pathPrefix="/channel/" />
<data android:pathPrefix="/user/" />
<data android:pathPrefix="/c/" />
<!-- playlist prefix -->
<data android:pathPrefix="/playlist" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="youtu.be" />
<data android:pathPrefix="/" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="www.youtube-nocookie.com" />
<data android:pathPrefix="/embed/" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="vnd.youtube" />
<data android:scheme="vnd.youtube.launch" />
</intent-filter>
<!-- Hooktube filter -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="hooktube.com" />
<data android:host="*.hooktube.com" />
<!-- video prefix -->
<data android:pathPrefix="/v/" />
<data android:pathPrefix="/embed/" />
<data android:pathPrefix="/watch" />
<!-- channel prefix -->
<data android:pathPrefix="/channel/" />
<data android:pathPrefix="/user/" />
</intent-filter>
<!-- Invidious filter -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="tubus.eduvid.org" />
<data android:host="invidio.us" />
<data android:host="dev.invidio.us" />
<data android:host="www.invidio.us" />
<data android:host="redirect.invidious.io" />
<data android:host="invidious.snopyta.org" />
<data android:host="yewtu.be" />
<data android:host="tube.connect.cafe" />
<data android:host="invidious.kavin.rocks" />
<data android:host="invidious-us.kavin.rocks" />
<data android:host="piped.kavin.rocks" />
<data android:host="invidious.site" />
<data android:host="vid.mint.lgbt" />
<data android:host="invidiou.site" />
<data android:host="invidious.fdn.fr" />
<data android:host="invidious.048596.xyz" />
<data android:host="invidious.zee.li" />
<data android:host="vid.puffyan.us" />
<data android:host="ytprivate.com" />
<data android:host="invidious.namazso.eu" />
<data android:host="invidious.silkky.cloud" />
<data android:host="invidious.exonip.de" />
<data android:host="inv.riverside.rocks" />
<data android:host="invidious.blamefran.net" />
<data android:host="invidious.moomoo.me" />
<data android:host="ytb.trom.tf" />
<data android:host="yt.cyberhost.uk" />
<data android:host="y.com.cm" />
<data android:pathPrefix="/" />
</intent-filter>
<!-- y2u.be filter -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="y2u.be" />
<data android:pathPrefix="/" />
</intent-filter>
<!-- Soundcloud filter -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="soundcloud.com" />
<data android:host="m.soundcloud.com" />
<data android:host="www.soundcloud.com" />
<data android:pathPrefix="/" />
</intent-filter>
<!-- Share filter -->
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<!-- media.ccc.de filter -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="media.ccc.de" />
<!-- video prefix -->
<data android:pathPrefix="/v/" />
<!-- channel prefix-->
<data android:pathPrefix="/c/" />
<data android:pathPrefix="/b/" />
</intent-filter>
<!-- PeerTube filter -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="eduvid.org" />
<data android:host="framatube.org" />
<data android:host="media.assassinate-you.net" />
<data android:host="peertube.co.uk" />
<data android:host="peertube.cpy.re" />
<data android:host="peertube.mastodon.host" />
<data android:host="peertube.fr" />
<data android:host="tilvids.com" />
<data android:host="tube.privacytools.io" />
<data android:host="video.ploud.fr" />
<data android:host="video.lqdn.fr" />
<data android:host="skeptikon.fr" />
<data android:host="media.fsfe.org" />
<data android:pathPrefix="/videos/" /> <!-- it contains playlists -->
<data android:pathPrefix="/w/" /> <!-- short video URLs -->
<data android:pathPrefix="/w/p/" /> <!-- short playlist URLs -->
<data android:pathPrefix="/accounts/" />
<data android:pathPrefix="/a/" /> <!-- short account URLs -->
<data android:pathPrefix="/video-channels/" />
<data android:pathPrefix="/c/" /> <!-- short video-channels URLs -->
</intent-filter>
<!-- Bandcamp filter for tracks, albums and playlists -->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH"/>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="http"/>
<data android:scheme="https"/>
<data android:host="*.bandcamp.com"/>
</intent-filter>
<!-- Bandcamp filter for radio -->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH"/>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="http"/>
<data android:scheme="https"/>
<data android:sspPattern="bandcamp.com/?show=*"/>
</intent-filter>
</activity>
<service
android:name=".RouterActivity$FetcherService"
android:exported="false" />
<!-- opting out of sending metrics to Google in Android System WebView -->
<meta-data android:name="android.webkit.WebView.MetricsOptOut" android:value="true" />
<!-- see https://github.com/TeamNewPipe/NewPipe/issues/3947 -->
<!-- Version < 3.0. DeX Mode and Screen Mirroring support -->
<meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
<!-- Version >= 3.0. DeX Dual Mode support -->
<meta-data android:name="com.samsung.android.multidisplay.keep_process_alive" android:value="true"/>
</application>
</manifest>

Android intent redirect from user shows no UI

I am running some kind of OAuth challenge on my mobile app and the flow is something like this:
User enters email address and clicks on "Sign In".
Goes to a browser -> presses a button and this action redirects him back to the sign in activity page.
As updated (in Edit 2), flow is from SignInActivity -> Browser -> SignInactivity (updated above).
This is the current flow. In the SignInActivity, I use the following 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" />
<data android:scheme="com.alpha.beta" android:host="signin" />
</intent-filter>
The issue is that when the button is clicked and the focus returns back to the application — the SignIn view shows no UI.
EDIT 1
PS: The code is in c# as I am using Xamarin.
I have been asked to post some code but this is a bit hard. Here's what I have:
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.AlphaBeta.AlphaBeta" android:versionName="1.1.1" android:versionCode="7">
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="19" />
<application android:name="AlphaBeta.Application" android:label="AlphaBeta" android:icon="#drawable/icon" android:debuggable="true">
<activity android:label="#string/appName" android:name="AlphaBeta.SignInActivity" android:screenOrientation="portrait" android:configChanges="orientation" android:noHistory="true">
<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.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</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" />
<data android:scheme="http" />
<data android:host="*" />
<data android:pathPattern=".*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\..*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.AlphaBeta" />
<data android:mimeType="*/*" />
</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" />
<data android:scheme="https" />
<data android:host="*" />
<data android:pathPattern=".*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\..*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.AlphaBeta" />
<data android:mimeType="*/*" />
</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" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\..*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.AlphaBeta" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.AlphaBeta" />
<data android:mimeType="*/*" />
</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" />
<data android:scheme="content" />
<data android:mimeType="application/octet-stream" />
</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" />
<data android:scheme="com.AlphaBeta.AlphaBeta" android:host="sso" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
</manifest>
SignInActivity.cs
public class SignInActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
}
protected override void OnResume()
{
base.OnResume();
Android.Net.Uri redirectUriFromBrowser = this.Intent.Data;
if (redirectUriFromBrowser != null)
{
// Redirect from user to continue with the SignIn flow
string SignInToken = SignInTokenFromUri(redirectUriFromBrowser);
if (singleSignOnToken == null)
{
HandleSignInFailure(this);
}
else
{
HandleSignInSuccess(this);
}
}
else ...
}
...
}
EDIT 2:
I am just wondering if the android intent-filter is somehow incorrect in the current use case. Please note the flow is from SignInActivity -> Browser -> SignInactivity (updated above).
EDIT 3:
Browser call:
Uri loginUri = Uri.Parse(user.SignInLink);
Intent SignInIntent = new Intent(Intent.ActionView, loginUri);
this.StartActivity(SignInIntent);
As you may notice from the comments, I was setting the UI in one of the if-else blocks and they weren't being called. This usually happens when you either write bad code or stare at the screen for more than unusual hours. Probably later.

Android file associations not working (intent filter, by extension)

I've been trying to associate my app with vrtci file extension, but it's not working. I've been looking across the internet to see what I've been doing wrong and nothing helped. Here is the section in my AndroidManifest.xml:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:theme="#style/Theme.AppCompat.Light">
<activity
android:name=".MainCardActivity"
android:label="#string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".CardInstaller" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:pathPattern=".*\\.vrtci" />
<data android:mimeType="application/octet-stream" />
</intent-filter>
<!-- For http -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:pathPattern=".*\\.vrtci" />
<data android:pathPattern=".*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.vrtci" />
<data android:mimeType="*/*" />
</intent-filter>
<!-- For https -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="https" />
<data android:host="*" />
<data android:pathPattern=".*\\.vrtci" />
<data android:pathPattern=".*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.vrtci" />
<data android:mimeType="*/*" />
</intent-filter>
<!-- For file browsers and google drive -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.vrtci" />
<data android:pathPattern=".*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.vrtci" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
</application>
So I've just found a solution which did it for me.
Create intent-filter with scheme "content" and do not specify the host element at all.
<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="content" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.vrtci" />
<data android:pathPattern=".*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.vrtci" />
</intent-filter>

How to Show App's Name in "Completing action using" menu?

I tried to use implicit intent to open my android app. It almost works, my app icon really appears in the menu "completing action with". However, instead of showing the real app name, as all the other applications do, the name appeared below the icon of my app is the package name, like "com.example.xxx", which is not quite user friendly. Where can I define this name?
Here's the code I used in the manifest xml:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.testImplicitIntent.MainActivity"
android:label="#string/app_name" >
<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.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:pathPattern=".*\\.txt" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:mimeType="application/txt" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.txt" />
</intent-filter>
</activity>
</application>
There is some problem with your #string#/app_name
Inside the intent filter in each intent filter give the android label
<activity
android:name="com.example.testImplicitIntent.MainActivity"
android:label="#string/app_name" >
<intent-filter android:label="#string/app_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:label="#string/app_name" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:pathPattern=".*\\.txt" />
</intent-filter>
<intent-filter android:label="#string/app_name" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:mimeType="application/txt" />
</intent-filter android:label="#string/app_name" >>
<intent-filter android:label="#string/app_name" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.txt" />
</intent-filter>
</activity>

Application not called when i click a link

I'm developing an android app and I would like to open my application when a link for file download on a certain website is clicked. I've read some guides for Android manifest file and this is the manifest I'm using:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ada"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET"/>
<application android:label="#string/app_name" android:icon="#drawable/ic_launcher">
<activity android:name="MyApp"
android:label="#string/app_name">
<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" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="application/*" />
<data android:mimeType="audio/*" />
<data android:mimeType="image/*" />
<data android:mimeType="message/*" />
<data android:mimeType="multipart/*" />
<data android:mimeType="text/*" />
<data android:mimeType="video/*" />
<data android:scheme="https"
android:host="my.subdomain.com" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="application/*" />
<data android:mimeType="audio/*" />
<data android:mimeType="image/*" />
<data android:mimeType="message/*" />
<data android:mimeType="multipart/*" />
<data android:mimeType="text/*" />
<data android:mimeType="video/*" />
<data android:scheme="http"
android:host="my.subdomain.com" />
</intent-filter>
</activity>
</application>
</manifest>
The problem is that when I browse my.subdomain.com/somefile.ext (with https or http), a download starts without asking me if I want to open the link with my app.
What am I missing?
You probably have to define the scheme attribute (https://developer.android.com/intl/es/guide/topics/manifest/data-element.html)

Categories

Resources