I want to make my app to get opened when user enters particular url in the browser like chrome or internet.For this i have referred and googled about this topic what i noticed is similar and i have used in my manifest file but still doesnt work.
i have referred below links for my issue
Launching custom Android application from Android browser / Chrome
Launch custom android application from android browser
How to open android application when an URL is clicked in the browser
Intercepting links from the browser to open my Android app
All this have same answer but when i use this it has no effect,when i type url www.myurl.co.gdf or http://www.myurl.co.gdf it doesnt prompt the user it opens in browser itself instead of opening myapp or showing choose dialog box
the code i have used in manifest file is as follows
<application
android:icon="#drawable/logo"
android:label="#string/app" >
<activity
android:name="com.app.secondActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/service"
android:screenOrientation="portrait"
android:theme="#style/aa_theme" >
<intent-filter android:label="#string/app" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data
android:host="www.myurl.co.gdf"
android:pathPrefix="/"
android:scheme="http" >
</data>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.VIEW" />
</intent-filter>
</activity>
<activity
android:name="com.app.firstActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/activity_title"
android:screenOrientation="portrait"
android:theme="#style/aa_theme" />
</application>
If this works fine for others why not for me?
Note:i have changed to above code only in manifest and i have not changed or added any thing extra in .java files or anyother files.
For this to work should i make any device setting changes or should i add Uri intentUri = getIntent().getData(); in .java file (should use then why?)or should i type differently in browser or have i used intentfilter in wrong activity or is there anything i am missing?
one more thing i am using some cordova plugins to this app, i dont think this has to do with opening an app.
I am very new to android please give me some ideas regarding this..
The issue isn't with your code- it is with your testing strategy.
Typing a URL in a browser does not typically start an Intent, and thus Android doesn't check to see if any other apps can handle the URL. When a user types a link into Chrome, for example, Chrome assumes that the user wants to continue using Chrome and will handle browsing to the URL itself.
Instead, you need to create an intent containing your URL to test if Android will handle deep links to your application correctly.
The easiest way to do so is via the following ADB command:
adb shell am start
-W -a android.intent.action.VIEW
-d http://www.myurl.co.gdf/
Related
I'm not even sure if this is possible, but this is what I would like to do.
Give the user an option to share some content (such as an inventory item). This is easy enough to do with and Intent using ACTION_SEND. However, if the other person has the same app installed the link should take them to my app and pass in what data was sent to them (so the app can show it to them). If they don't have the app, it should take them to the app store to encourage them to download the app.
Is this possible, and if so how is it done?
As described in this link : Create Deep Links
You should add this in your manifest :
<activity
android:name="com.example.android.GizmosActivity"
android:label="#string/title_gizmos" >
<intent-filter android:label="#string/filter_view_http_gizmos">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmosā -->
<data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="/gizmos" />
<!-- note that the leading "/" is required for pathPrefix-->
</intent-filter>
</activity>
and then share a link that starts with "http://www.example.com/gizmos" (fake url) with another person.
Yes it is possible by handling adding state parms in your url and then redirecting to play store from your server side code.
eg - your app generates url which points to some user profile -
https://www.yourSocialNewtwork.com/profile/sandeshDahake
Step 1 - Create a deep link in your app with intent filter. This will handle your app is already installed and pass params to it -
<data android:scheme="https"
android:host="www.yourSocialNewtwork.com"
android:pathPrefix="/profile" />
Step2 - If app is not installed you can redirect to play store from your server side
https://developer.android.com/google/play/installreferrer/library#java
https://play.google.com/store/apps/details?id=com.profile.yourHierarchy &referrer=sandeshDahake
I have heard there are some opensource projects which handle this scenario but not explored them yet.
Basically trick here is proper url structure and deep linking.
https://developer.android.com/training/app-links/deep-linking
I want the callback of an oauth2 authentication to redirect to my app. I know about chrome's intent filter but it requires the user to manually ask the app to open. I read on the internet it's not possible to do it automatically but apps like Instagram or even Google's IO app have the ability to be open from the browser (here are some examples https://instagram.com/_u/instagram and https://events.google.com/io/schedule). I've also tried intent filters (in the manifest) but them don't work either. I don't require the app to be triggered by the callback url in the oauth, if needed I could use a backend. How do I achieve that?
What you need Deep linking. To open your app on link click you need to add intent filer "android.intent.action.VIEW" in manifest.
<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="example.com"
android:pathPrefix="/api/v1/view"
android:scheme="http" />
</intent-filter>
Once you build a link with same signature as mentioned in manifest The android system will add your app in chooser to open link in your app and you will get the data in "getIntent().getData()" in respective Activity.
If app is not installed the link will itself open in browser.Then handle it on browser .
To send intent from browser you need to follow same schema as manifest.
"intent://example.com/api/v1/view#Intent;scheme=http;package=com.app;category=android.intent.category.BROWSABLE;component=com.app.yourActivityname;action=android.intent.action.VIEW;end
Suppose I have an app with the following intent filter in an activity in the AndroidManifest.xml file:
<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="blabla.com"
android:pathPrefix="/element/"
android:scheme="http" />
</intent-filter>
Of course it will cause my app to be launched from the browser, for example. However, when the user clicks on the link, it is asked to select the application for opening that link. If he/she selects a browser instead of my app and, in addition, he/she checks the "don't ask me again" check box, my app will never be launched!
Is there any way to avoid that?
Is there another kind of URI I can use to uniquely open my app? I have been looking for answers in StackOverflow but I have not found any good example of a non browsable URI for launching my app from a link.
Thank you so much,
Use an with a element. For example, to handle all links to twitter.com, you'd put this inside your in your AndroidManifest.xml:
<intent-filter>
<data android:scheme="http" android:host="twitter.com"/>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
Then, when the user clicks on a link to twitter in the browser, they will be asked what application to use in order to complete the action: the browser or your application.
Of course, if you want to provide tight integration between your website and your app, you can define your own scheme:
<intent-filter>
<data android:scheme="my.special.scheme" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
Then, in your web app you can put links like:
<a href="my.special.scheme://other/parameters/here">
And when the user clicks it, your app will be launched automatically (because it will probably be the only one that can handle my.special.scheme:// type of uris). The only downside to this is that if the user doesn't have the app installed, they'll get a nasty error. And I'm not sure there's any way to check.
Use a custom scheme instead of http. Maybe, x-myapp
<data
android:host="blabla.com"
android:pathPrefix="/element/"
android:scheme="x-myapp" />
Have your blabla.com web server respond to http links (http://blabla.com/element/foo) with a redirect to x-myapp://blabla.com/element/foo for mobile android devices.....or put a link on the page that will have the x-myapp:// link for the user to tap
Now since your app is the only one responding to x-myapp://blabla.com/element/ links, you have avoided step 1.
I'd like to create an app that responds to home clicks (double-tap home clicks) and then can launch an app. I need the app to be constantly on, so I understand that I need it as a service... but I have not found a way to respond to home clicks and read/recognize them, is there any possible way that there is something like this in the API?
Thanks
The home-button is supposed to open the (a) launcher. You can define your app to be a launcher by Intent-Filter in the Android Manifest:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
The negative impact is that it always opens your app if you push the home button.
I would like to have my application respond to the market link for my application. So the link is market://details?id=my.package.name. Now the reason I want this is so I can send out a link that will open the app if it is installed and open the market page if the application is not installed. The problem I am running into is that my application will respond to all market links and not just my applications link. The reason is the package name is defined in the query part of the Uri. Is there a way to filter an intent based on the query part of the Uri?
From Android API 19, you can do it, using ssp, sspPrefix or sspPattern. Example:
<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"
android:sspPrefix="//play.google.com/store/apps/details?id=com.example.test"
/>
</intent-filter>
With such filter, the OS will offer your app only for URLs with id=com.example.test parameter, and won't offer it when there is no such parameter. But this works only on Android 4.4+, older versions will ignore sspPrefix.
See also this article: https://chris.orr.me.uk/android-ssp-data-intent-filter/.
No, sorry, you cannot. You can constrain a filter based on everything to the left of the ?, but that's it.