Is it possible to receive content just from the YouTube app?
When a user clicks the share button inside the YouTube App (and no other app/browser), my app should be listed in the share dialog.
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data
android:host="???"
android:scheme="???"
android:mimeType="text/*"/>
</intent-filter>
Can I filter by package name?
Have you tried:
<data android:host="com.google.android.youtube" />
in your intent filter?
If that doesn't work, then your best course of action would be to register it as a normal "share" broadcast receiver and log various elements of the broadcast to the console, then compare shares from YouTube to all other apps.
Related
I want to write a NFC tag that opens a specific note in Google Keep when touched.
I have an URL in the form of https://keep.google.com/u/0/#LIST/<id> that does the desired action of opening the note in the installed Google Keep app on my phone when I read it with a QR-reader or click on it as a link.
When I write this URL to the tag an touch the tag afterwards, it opens in the browser. Is the NFC handler skipping other apps and opening it directly in a browser? When I clear the app-defaults for the browser, it shows a selection menu for the installed browsers after tapping the tag. Does anyone have an idea what I am doing wrong?
Links on NFC tags are not launched as intents with the typical VIEW action. Consequently, other apps may not pick those links up correctly and you will instead experience the web browser to be opened. Only apps that specifically register for the intent action NDEF_DISCOVERED will be able to receive links from NFC tags. It seems that Google Keep currently does not do this, so there's not much you can do without creating your own wrapper app that handles these URLs and passes them on to Google Keep.
You should enable deeplinks in your activity. Also you should indicate your activity NFC tag discoverable as follows. You can learn anything about deep linking via this link
<activity
android:name="ExampleActivity"
android:label="Example">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="example.com"
android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
I couldn't find anything on this. I read everything about protocol/content handlers but didn't seem to solve my problem at all.
I'm trying to find a way to allow an Android user (for example) to share content using a web application.
Examples:
1) Viewing a Youtube video in the native app. User selects 'share' and a bunch of icons appear. I want my web app to be there, so when user selects its icon, a URL is opened in the browser with a magic parameter passing the video URL so I can handle that.
2) Well, you get the idea now :)
Any ideas?
Thanks.
If your app can do some task and you want that message to be conveyed to all other apps, Android way of doing this is - Intent Filters (It tells the world what the app can do)
Intent - Android way of telling - Hey i want to get this job done ?
If you build a social app that can share messages or photos with the user's friends, your app should support the ACTION_SEND intent. so users can initiate a "share" action from another app and launch your app to perform the action.
To allow other apps to start your activity, you need to add an element in your manifest file for the corresponding element.
If your activity handles both text and images for both the ACTION_SEND and ACTION_SENDTO intents. In this case, you must define two separate intent filters for the two actions because a ACTION_SENDTO intent must use the data Uri to specify the recipient's address using the send or sendto URI scheme. For example:
<activity android:name="ShareActivity">
<!-- filter for sending text; accepts SENDTO action with sms URI schemes -->
<intent-filter>
<action android:name="android.intent.action.SENDTO"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="sms" />
<data android:scheme="smsto" />
</intent-filter>
<!-- filter for sending text or images; accepts SEND action and text or image data -->
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="image/*"/>
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>
This link has all the above mentioned details with lot more information.
http://developer.android.com/training/basics/intents/filters.html
I defined the following intent filter in my application in order to make it respond to url links.
<intent-filter>
<data android:scheme="http"/>
<data android:scheme="https"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
Now when I click a link in an external app (from example a link sent by sms) it opens my app in an embedded way in the current application. Meaning that if I go to background I see my app inside the sms application.
I want the link to make my application to be opened separately. This is the correct behaviour, and happens for example when choosing chrome/ android native browser as the app to open the link.
Is there a way to change that for my app as well?
You have to set the launchMode of your activity to singleTask or singleInstance. This will force the system to open a new task for your app instead of opening it in the same task as the sms-app or whatever.
It should look somehow like this:
<activity android:name="yourActivity"
android:launchMode="singleTask">
</activity>
For more information, see the documentation: http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
I am working on an application where i have to create a link of my application and copy that link to text buffer and paste that link in my device in any text editor. Now when i tap on that link my application should open and show appropriate data. I don't know how to implement this i searched on internet I did not find any solution which can explain this feature implementation. give me the best way to implement this.
I have tried this but can not understand
Launch your application when a link taped
You have to use other app to start it. You should register intent-filter with other action and category in your app. The most common action should be ACTION_VIEW combine with category BROWSABLE, then you can use a url in brower or sms to open you app. The intent-filter should be like:
<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="openmyapp"
android:scheme="http" />
</intent-filter>
Is there a way to set your applications "type"? For example, If I download Opera for Android and then in another application I click a web URL, Android will ask me do I want to open the link with the default browser or with Opera. How do Opera achieve this?
EDIT specifically, how would I pass the URL into my activity?
You should read about activities and intent-filters.
Here is a good starting point: Activities, and specifically Intent Filters section.
This is done via the mechanism of Itent filters, that are defined in your Manifest.xml.
I think Opera has probably an intent filter like this set on the main activity :
<intent-filter>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="android.intent.action.VIEW"/>
<data android:scheme="http"/>
</intent-filter>
Then when the opening of a web page is requested via a sent Intent, the system will search through its database, which application can answer it and propose the applications to the user.
I think you have to study intent-filters. Here is the short text from android docs.
"Components advertise their capabilities — the kinds of intents they can respond to — through intent filters. Since the Android system must learn which intents a component can handle before it launches the component, intent filters are specified in the manifest as elements. A component may have any number of filters, each one describing a different capability."
Specifically for a browser I suppose that you have to register it like below:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http"/>
</intent-filter>