Select application to open links with in Android - android

I want to write an app that allows me to remotely start downloading a torrent on my desktop from my phone. How can I change android to open magnet links with my app? I'm trying to find a non-browser specific solution that can be executed on install without the user having to go through settings.
EDIT:
Something like this?
<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="magnet" />
<data android:host="*" />
<data android:mimeType="application/myApp" />
</intent-filter>

I'm trying to find a non-browser specific solution that can be executed on install without the user having to go through settings.
Im not quite sure I understand what exactly you are trying to do with links. But I can tell you that it probably isn't going to work the way you want it on any stock devices. There is no mechanism within the system to let your application start doing anything right after it is installed. At the very least the user is going to have to choose to use your application to handle whatever links you are trying to override.

Related

Android - Setting the app's default "Open supported links" option

How can I control the default Open supported links to either Ask every time or Open in this app for my Android app? Does it happen in the manifest?
I have two apps that try to accept the same universal link scheme, and the ideal behavior is to have the user decide which app to open when they click on the link. However, it seems that the first app correctly has the Open supported links in settings set to Ask every time, while the other app has the Open supported links as Open in this app. Thus, when both apps are installed, only the second one will be opened straight away, whereas the first one won't even be prompted.
The portion that accepts universal links in both of the AndroidManifest.xml files are almost identical.
<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="foo.bar.com" android:pathPrefix="/action/" android:scheme="https" />
</intent-filter>

How to open an application from a URL?

My objective is to open my android application when user clicks link e.g I have shared specific item link (http://example.com/api_shirts.php?utmsource=shirt98) then if user have already installed my application then open it else where open it on browser.
I have searched a lot and get this but it's not working for me
<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.example.com" />
<data android:scheme="https"
android:host="www.example.com"/>
</intent-filter>
I'm not sure if you may need to set a pathPrefix on this case. Also, the OS may open other prefered app that the user has set up as default app for that schema.
If I remember correcly you have to associate your app with your website so the OS can open the app directly bypassing the user's choice:
https://developer.android.com/studio/write/app-link-indexing.html#associatesite
Also, check https://developer.android.com/training/app-links/verify-site-associations.html to read about "deep links" vs "app links". You need app links for what you are trying to do.

Android sending simple data -- app can share to it self?

I have an application which has a file browser and a created image viewer. In these activities we can share.
I added the option to receive simple data (shares) from other applications by adding the the manifest
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/jpeg" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/jpeg" />
</intent-filter>
The issue is, I receive shares from elsewhere no problem. I share within the application, I can select, my application. I would like it to not be sharable to my application from my application. I see apps such as the samsung gallery does not suffer this annoying problem (which means there is a fix and I cannot ignore it)
The Samsung gallery app actually does not show up in its own share menu because you cannot share files via that app, but only view them.
If you are severly annoyed by your app appearing in the system-built chooser dialog, you could always build your own. Simply get all the apps that you could use for sending via PackageManager.queryIntentActivities(android.content.Intent, int), then display them in a custom dialog.

Run Application via link

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>

Handle ics/vcs files in my Android app, correct Intent Filter

I've seen this question asked 100+ times but none of the answers are working for me. I want my app to handle all files with ics or vcs extensions, *no matter where they come from. *Except, I don't want to have to download them myself if they come from http/https, I just want the browser to at least let the user save them and then open with my app. Currently the browser says "content not supported on this phone".
Here is what I currently have, but I've been trying everything:
<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:host="*" />
<date android:mimeType="text/calendar" />
<data android:scheme="https" />
</intent-filter>
With the above, when I click an https link, one that comes from my server and I know my server is sending the text/calendar mime-type, the droid asks what app they want to use to open the link. The list has my app or the browser. If I select my app, it runs my activity and gives me the Uri. I want the browser to download the file though, I don't want to have to download it myself... same way other file types work, images, pdfs, etc. If I select the browser, it starts the download but then stops with a "content not supported on this phone" error.
I also tried this:
<intent-filter >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:host="*" />
<data android:scheme="file" />
<data android:pathPattern=".*\\.ics" />
</intent-filter>
Also tried with the scheme set to "content", and lots of other variations I found on SO and other places.
You should consider that the browsers are implementing this download behavior for binary files and you can not change it by a intent-filter.
Other applications like pdf viewer declare an intent-filter identical to your second approach (except for the file-extension).
Therefore I would recommend to just download the file yourself. As it just requires a few lines of code this should not be a big problem.

Categories

Resources