Android tries to verify host despite android:autoVerify="false" - android

In my app I have 3 activities, MainActivity, SecondaryActivity and TertiaryActivity. I want SecondaryActivity to be a default app link handler for a particular domain on Android 6, as described in this guide. At the same time, I want another activity, TertiaryActivity, to be able to handle links from another domain, but not be a default handler, as I don't own the domain. Here's my AndroidManifest to illustrate:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.antonc.applinktest"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".SecondaryActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter android:autoVerify="true"> <!-- TRUE -->
<data android:scheme="https"
android:host="secondary.com"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
<activity android:name=".TertiaryActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter android:autoVerify="false"> <!-- FALSE -->
<data android:scheme="https"
android:host="tertiary.com"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
</application>
</manifest>
I read through this extensive guide on app links that explains the mechanics of app link handling and app verification on Android, and here's the messages I see in logcat related to app verification:
03-25 17:54:45.640 1481-1481/com.google.android.gms D/IntentFilterVerificationReceiver: Received ACTION_INTENT_FILTER_NEEDS_VERIFICATION.
03-25 17:54:45.644 1481-30947/com.google.android.gms I/IntentFilterIntentService: Verifying IntentFilter. verificationId:12 scheme:"https" hosts:"tertiary.com secondary.com" package:"com.antonc.applinktest".
03-25 17:54:46.762 1481-30947/com.google.android.gms I/IntentFilterIntentService: Verification 12 complete. Success:false. Failed hosts:tertiary.com,secondary.com.
As you can see it attempts to verify both secondary.com and tertiary.com, even though I explicitly set android:autoVerify="false" for the intent filter on tertiary.com!
Is this an Android bug? How do I make sure that IntentFilterIntentService only verifies the intent filter for which I have set android:autoVerify="true" and leaves the other one out?

Is this an Android bug?
Since the behavior appears to be documented, I would describe it as a limitation. Quoting the documentation:
When the android:autoVerify attribute is present, installing your app causes the system to attempt to verify all hosts associated with the web URIs in all of your app's intent filters.
(emphasis added)
My interpretation of that is that if auto-verify behavior is all-or-nothing at the app level. It is unclear to me why they wrote it that way. If that is the long-term plan, I would have expected the autoVerify attribute to be on <application>.
How do I make sure that IntentFilterIntentService only verifies the intent filter for which I have set android:autoVerify="true" and leaves the other one out?
Put them in separate apps, I guess.

I think you should leave out that android:autoVerify="false" instead of setting it.
Reading the documentation it says only if the attribute it present. It wont check the value.
When the android:autoVerify attribute is present, installing your app
causes the system to attempt to verify all hosts associated with the
web URIs in all of your app's intent filters.

If you do not add
android.intent.category.BROWSABLE
This will prevent Android from auto verifying that particular intent-filter.

Related

Multi instance in Redirect URI with openid / AppAuth-Android

when I use this library:
https://github.com/openid/AppAuth-Android
have an issue when trying to use the deep link and open application. in this case, I have a multi-instance of my app with the same name and package name. I want to just one instance. (when I touch in one of the instances redirect happen but when touching the other one nothing happen)
everything works perfectly good and only I have this issue.
I saw these issues too:
https://github.com/openid/AppAuth-Android/issues/329
https://github.com/openid/AppAuth-Android/issues/481
https://github.com/openid/AppAuth-Android/issues/491
and this is my code inside manifest:
<activity
android:name=".util.deeplink.appAuth.RedirectUriReceiverActivity"
tools:node="replace">
<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="test"
android:host="ops" />
</intent-filter>
</activity>
we found the solution. we have to just add
<activity android:name="net.openid.appauth.RedirectUriReceiverActivity"
tools:node="replace"/>
besides our custom class:
<activity
android:name=".util.deeplink.appAuth.RedirectUriReceiverActivity"
android:windowSoftInputMode="stateAlwaysHidden">
into manifest file

Why is my app not showing in the grid of icons (not the launcher) after installation

I recently started testing my react-native android application and noticed that it doesn't create an app icon on installation. When I debug - it seems to install and run fine, but when I look for it in the app icon to launch - it does not show up. Looking at the list of installed apps, it's there. How can I debug this? Do I need to change the launch mode from singleTop to something else? I tried changing it to singleInstance and it still had the same issue. If I remove some of the intent filters it seems to work - so maybe I messed up the branch.io installation instructions? Do I need to create a seperate intent filter xml node for the other intents? https://dev.branch.io/getting-started/sdk-integration-guide/guide/react/#android-configure-manifest
AndroidManifest.xml
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:launchMode="singleTop"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<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"
android:host="www.foo.com"
android:pathPrefix="/event" />
<!-- note that the leading "/" is required for pathPrefix-->
<data android:scheme="fooapp" android:host="open" />
</intent-filter>
<intent-filter>
<action android:name="fcm.ACTION.EVENT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Update
Splitting up the intent-filters seems to have fixed it - but a bit unclear if that is the correct thing to do. In the branch.io instructions - did they mean for me to create a new intent-filter and not add to the existing main one?
<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" />
<data android:scheme="http"
android:host="www.foo.com"
android:pathPrefix="/event" />
<!-- note that the leading "/" is required for pathPrefix-->
<data android:scheme="fooapp" android:host="open" />
</intent-filter>
The launcher is typically specific software developed by the individual hardware manufacturers. On all of the devices i have, an app does not get installed on the homescreen when it is not installed from the play store, but it does show up in the list of apps. However, that behaviour will be specific to the launcher you are using i think.
You should not need to go to settings->apps though just to see it. Is that the problem you are having?
Perhaps a screenshot as well as a description of your test device (s) would make the question clearer.
Update....
Typically the startup activity has one intent filter with only MAIN and LAUNCHER. I would just try to remove the other things from that intent filter and see if that resolves the problem. Then one by one, add the rest of the things you have listed until you identify the problem child.
Looking at this again, I am not sure that you can define 2 actions in a single event filter. So it seems you need to remove VIEW.

Android Custom Intent Cannot Start Activity (Yes, I include the DEFAULT category)

I have searched and searched and cannot seem to find the answer to this specific question about a custom intent.
I have an application with 4 activities, 1 is the main that sets things up and the other 3 represent the different screens I present to the user. I am trying to use custom intents to start the different activities.
Here is my AndroidManifext.xml:
<?xml version="1.0" encoding="utf-8"?>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Activities.REDB_main" android:label="#string/app_name"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activities.ChooseCards" android:launchMode="singleTop">
<intent-filter>
<action android:name="#string/ACTION_VIEW" />
<action android:name="#string/ACTION_REFRESH" />
<category android:name="#string/CATEGORY_SHUFFLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".Activities.SelectSets" android:launchMode="singleTop">
<intent-filter>
<action android:name="#string/ACTION_VIEW" />
<action android:name="#string/ACTION_REFRESH" />
<category android:name="#string/CATEGORY_SELECT_SETS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".Activities.SelectCards" android:launchMode="singleTop"
android:permission="android.permission.ACCESS_CHECKIN_PROPERTIES">
<intent-filter>
<action android:name="#string/ACTION_VIEW" />
<action android:name="#string/ACTION_REFRESH" />
<category android:name="#string/CATEGORY_SELECT_CARDS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
I create a category for each application and then the two kinds of actions I want it to handle. I know that I could use explicit intents, but since I want to have different actions I figured that making the implicit intents would work better.
I call the first of my real activities from within my main with this:
Intent intent = new Intent().setAction(getString(R.string.ACTION_VIEW));
intent.addCategory(getString(R.string.CATEGORY_SHUFFLE));
startActivity(intent);
Of course, the reason I am here is because the above can never find the activity that matches the intent. The error messages states the action and category correctly and unless I'm wrong, the above manifest creates the intent-filters correctly.
Searching around online, I always seem to find examples with data also being used. I messed around with adding data just to see if it was necessary but it did not seem to matter.
On a slightly different note, is there a different way I should be controlling the flow of my program besides intents? The reason I have two actions is because 1 switches the view while the other is there to just refresh the data so that when the user switches to the screen later, they don't see it quickly refresh the data but instead just the new stuff.
I know that I could use explicit intents, but since I want to have different actions I figured that making the implicit intents would work better.
I rather doubt that. Mostly you use <intent-filter> when you want things other than your own app to start the component (e.g., third party apps).
Also, I doubt you want android:launchMode="singleTop" on all of those. And I am very certain that you do not want android:permission="android.permission.ACCESS_CHECKIN_PROPERTIES" on the last one, as you won't be able to launch your own activity then, most likely.
The error messages states the action and category correctly and unless I'm wrong, the above manifest creates the intent-filters correctly.
I have never seen an Android application use a string resource for a <category> element. Perhaps that is contributing to your difficulty. Also, since the <category> elements are not doing you any good that I can see (except your LAUNCHER one), I am unclear why you put them there.
I suggest that you just drop the <intent-filter> elements and use explicit Intents.
Don't use resource strings to make intents actions, use android.intent.action.VIEW instead

Android Activity order

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="muazam.multiplication.one"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="3" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:label="#string/app_name" android:name=".multiplication">
<intent-filter android:priority="1">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="#string/app_name" android:name=".splash">
<intent-filter android:priority="3">
<action android:name="android.intent.action.CLEARSCREEN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:label="#string/app_name" android:name=".Menu">
<intent-filter android:priority="2">
<action android:name="muazam.multiplication.one.Play" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
I want it to start with the .splash class first, and then .Menu class.
As you see I have put android:priority on them, but it seem to do nothing.
Anyone know how to solve this problem? Thanks.
I want it to start with the .splash class first
That has no meaning in Android.
If you meant to say "I want the .splash class to be what launches when the icon in the home screen launcher is clicked", then you need to get rid of the .splash class' current <intent-filter> (which is simply wrong) and move your MAIN/LAUNCHER <intent-filter> from the .multiplication class to the .splash class.
While you are at it, please get rid of the android:priority attributes (which are not used here) and your Play/DEFAULT <intent-filter> (which you really should not need, unless you plan on third-party apps starting up that activity directly).
and then .Menu class
You do this in Java code with startActivity().
As you see I have put android:priority on them, but it seem to do nothing.
Of course. There is no android:priority attribute for the <activity> element, as you can see in the documentation.
Activities aren't run automatically like a 'slide show' (although you could write your own code that way if you really wanted to).
The android:priority attribute is used for an entirely different purpose (from the docs for <intent-filter>...
It provides information about how able
an activity is to respond to an intent
that matches the filter, relative to
other activities that could also
respond to the intent. When an intent
could be handled by multiple
activities with different priorities,
Android will consider only those with
higher priority values as potential
targets for the intent.
In other word, if you have two activities each having an intent filter with the same action and category, then any Intent sent (from a 3rd party app) with those action/category details, will be passed first to the Activity whose intent filter has the highest priority.
This has nothing to do with how an app (and its activities) behave internally at runtime.

Android: APK Icon is not being installed

I am able to deploy my application but for some reason, I am not able to get the icon to display in the pull up menu on the Home page of the OS. Does anyone know what I can do to solve this?
By the way, the application shows up in "Manage Applications" but does not show up as an icon for some reason. Through Eclipse, I am able to start the application after deployment but that's it... After that, I don't have any way to start it because there is no icon. :( Following is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.ApplicationName"
android:versionCode="1"
android:versionName="2.0">
<application android:icon="#drawable/icon"
android:debuggable="true"
android:label="#string/app_name">
<activity android:name=".EntrySplash"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="com.android.ApplicationName"></data>
</intent-filter>
</activity>
<activity android:name=".EntryScreen" android:label="#string/app_name">
</activity>
<activity android:name=".ApplicationName" android:label="#string/app_name">
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
I had this problem as well, i think the fix that worked for me is i separated the intent tag like below
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="com.android.ApplicationName"></data>
</intent-filter>
when i changed my manifest file like that, my icon showed up.
Try getting rid of your android.intent.category.BROWSABLE and <data android:scheme="com.android.ApplicationName"> temporarily, and see if your icon shows up.
Also, on an unrelated matter, I recommend that your uses-* elements be the first children of manifest, not the last. There have been rumors of problems with the XML parsing done by the Android Market, where it wants to see those before any elements.
Had this same issue and found out that one caveat is that this correct intent on the main activity tag:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
has to be in its own intent filter. you may have other items in the main activity's intent filters, and if so, separate the rest out in to a separate intent filter tag right below it. leave the MAIN and LAUNCHER together in its own.
Alot of the answers to this question on SO seem to miss that point.
Hope it helps!
Well it is happening as you are giving two categories name to your launching activity. You launching activity should have only one category name in its Intent filter. But if you also need the Browsable activity then your Launching Activity may have 2 Intent Filters as show below.
You just replace your EntrySplash Activity code with the below code in you Manifest.xml file.
<activity android:name=".EntrySplash"
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>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="com.android.ApplicationName"></data>
</intent-filter>
</activity>
This will sure work for you...
This problem still exists in SDK v2.2. A few more suggestions in addition to the ones above if you want to publish to your phone from Eclipse. Try these if it's still not working and you don't feel like manually publishing. Remove all blank lines in the manifest. And make sure this line just has only icon and label properties in it:
<application android:icon="#drawable/icon" android:label="#string/app_name">
Apparently I found out that it works if I manually install the application using command line adb. So, in case you updated your ADT plugin and you experience problems, just install things manually...
I find that sometimes my assets don't update in the app when I add them to my projects.
There are two ways you can fix this problem:
Clean and rebuild the project.
Uninstall the app on your phone and install it from scratch using ADT.
Simple as that!
Just to add confirmation to CommonsWare's answer, I just came across this exact bug for a project targeting 2.3.3+. I had to Delete the following:
<data android:scheme="com.android.ApplicationName"></data>
Then I had to Clean the project. I think that having to use adb to install every time is a sign of something wrong with the Manifest, and will come back to bite you later (once in the Market specificially).

Categories

Resources