I feel like this is an embarrassingly stupid question, but oh well, as long as I get an answer.
The purpose of an app intent Nearby Notification is that users who tap the notification will be taken to the Play Store to install an app if they don't have it, or it will open the app if it is already installed. My problem is that, even when it is already installed, tapping the notification always takes me to the Play Store listing for the app.
In the Google Beacons dashboard, I select a beacon from the list and then select "View Nearby Notifications" from the dashboard. I enter a title, the language, ensure production mode is selected, select "App intent" from the dropdown. Then I have fields for intent scheme, intent path, package name of the app.
Is an intent path required?
Why isn't a host required?
I'm unclear about what intent filter I need to set in my AndroidManifest.xml. This is what I am trying:
<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="nearbyapidemo"
android:host="name.chadschultz.nearbyapidemo"/>
</intent-filter>
What am I doing wrong?
A kind developer in real life pointed out my mistake. This is all I need to add in AndroidManifest.xml for the Activity I want to start:
<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="nearbyapidemo"/>
</intent-filter>
I did NOT need a value for the host. Silly mistake on my part!
And then when I configure the beacons, I simply need to enter the scheme (whatever arbitrary value I entered for the scheme in AndroidManifest.xml and then the package name of the app. I can leave the path blank in both the manifest and the Beacon Console.
Now when I tap the Nearby Notification, it will install the app if not installed, or will open the app if it is installed.
Another tip I learned: I can test the Intent directly from ADB via
adb shell am start -a android.intent.action.VIEW -d "nearbyapidemo://" name.chadschultz.nearbyapidemo
(Replace nearbyapidemo with your scheme and name.chadschultz.nearbyapidemo with your package name)
Of course, the best test is to update the bluetooth beacon and tap the Nearby Notification when it appears.
Related
I'm trying to get an instant app to be opened via NFC.
I have something like the below in my AndroidManifest.xml
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<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="https" />
<data android:scheme="http" />
<data android:host="example-refresh.herokuapp.com" />
</intent-filter>
When going to https://example-refresh.herokuapp.com (example link obviously) from a link click the instant app loads correctly. When opening that link from an nfc tag the browser just loads. I've tried also having the nfc open an AAR (https://developer.android.com/guide/topics/connectivity/nfc/nfc.html#aar) this results in the play store link opening when the app isn't installed and the app correctly opening from the nfc when it is installed. If I have something else on the nfc so it shows the disambigious options then I can select instant app for the browser option, but I would like for it to default to instant app.
Is there something I'm missing to get an nfc tag to load an instant app? I've also tried using branch, but with no luck.
Instant apps have a very limited set of allowed permissions and NFC is not in that set. Thus any NFC related intent will not work. Besides, whatever you define on your manifest only works when your app is installed. Which obviously is not the case for instant apps. Google does index the android.intent.action.VIEW intents when you upload your APK to Play Store, so they can make instant app works.
So when you scan an NFC, it is an android.nfc.action.NDEF_DISCOVERED intent, and therefore your app won't be launched
However, you still can make it work. Instead of using the link you would normally use to launch your instant app, you should write the link to your instant app on the Play Store to your NFC tag.
https://play.google.com/store/apps/details?id=<package_name>&launch=true
Check https://developer.android.com/distribute/marketing-tools/linking-to-google-play#Instant
I want to launch a specific android app through a NFC card. I don't want android to ask me which app should be opened. It should instantly open my app. How could I do that?
I already tried it with MIME-Types but it did not work. Could i specify my own MIME-Type? Would it be possible to check the MIME-Type text/plain for a specific text(intent filter?)?
For example: I want my app to start when the NFC card has a specific text stored like "test" or something.
The idea is that it should work on every common mobile OS. Therefore an android application link would not work.
You can create your own application mimeType.
You could create a custom mimeType in your NDEF message and then create an intent-filter which matches it exactly. This would mean your app would be launched as it is the most specific filter.
Example:
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/vnd.com.my.app.package.customString" />
</intent-filter>
Taken from a previous example I've provided here: https://stackoverflow.com/a/27397938/3312868
In my app I have an intent filter set to match certain types of links if clicked in a web browser or other field. It currently looks like this:
<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.mydomain.com"
android:scheme="http" />
<data
android:host="mydomain.com"
android:scheme="http" />
<data
android:host="m.mydomain.com"
android:scheme="http" />
</intent-filter>
This works well. If you click a link say http://www.mydomain.com/article_name then the user gets the option of opening the article in the app and I can show the content uniquely. Here's the question - in the app I want to provide an option for the user to still break out and "Open in Browser". Yet if I do this and just try to fire off an intent to launch the browser, my app catches the link again and we go around in a circle.
How can I specifically force a link to be opened in the browser?
I believe you can use the answers provided in this thread to achieve your end. Basically, when you go to launch the "open in browser" intent, you can preview the activities that will be able to open it. From there, you can select one that isn't your app and set that as the package on the intent, which will cause the other app to open it.
At worst, you could force the creation of the chooser which would contain both your app and the other apps that can open your site, enabling the user to pick the browser.
This other question might also be useful, as its answers contain an implementation of a custom chooser which apparently allows you to filter the visible activities, so you could remove your app.
I don't know any way to bypass Android Intent Filter.
If user uses Android default Browser or Chrome, you should use the way in following link to open an Intent specifically.
https://developers.google.com/chrome/mobile/docs/intents
I am building an app that starts when a user takes a picture using their build-in Android camera, then taps the Share button, then chooses my app as the sharer, which is expecting an incoming path to the picture that was just taken, which it uses for processing.
Question: how do I add an option to the "Share via" list that points to my app? Right now there are options like Facebook, Email, Messages, Twitter, Picasa, and I want to add my app w/ an icon.
I'm stuck! And, Google'ing for this is not easy, as "android add to share via list camera" yields a lot of results. I'm building the app with AppInventor (AI), but, AI does not allow developers to edit the Share via list, so maybe this will have to be a separate mini app that just adds to the list...? Hopefully not, because it'd be great to have just 1 app for users to download/install.
Functions like the "share via" in Android work with broadcast intents. The app creates this intent and the system reports all the activities that can execute that (twitter, fb...) You specify what an activity can do by means of intent filters.
In your case I searched for "android camera share intent" and found generally that the intent filter looks like this:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
(not sure about the data section)
I don't know if camera app uses a specific content provider, anyway your app should be able to manage at least the URI scheme that app uses.
I wanted to Share text content and i add the below code in manifest and its works...
<activity android:name=".SendMessage.SendMessageLeads"
android:label="SMS Composer"
android:icon="#drawable/sms_composer">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
I've read many posts on stackoverflow and doc on the Android API in order to be able to catch links from SMS or mail. For example, if I receive a SMS containing a link like myapp://hello, I want to to be clickable and to open my application once clicked.
I found how to do it using an intent filter on the activity I want to activate. Here is my code:
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="myapp"></data>
I tried it first with android:scheme="http" and it worked well (when I clicked a link from a SMS, Android asked the user which app to use: browser or myapp).
However when I want to do so with myapp instead of http, it doesn't work...indeed the link myapp://hello is not clickable...so it's impossible to launch myapp clicking on it...
Do you have any idea ? Do I have to activate something, somewhere to tell Android to parse this kind of addresses ?
Thanks