Making WebView a Default phone browsaer - android

I have been searching the web, and I still can’t find the answer. I have an Android app with a WebView, I am trying to make my activity the default browser for the phone. Therefore when I do a Google search in the Google search widget, it should pass the results into my WebView.
I am new to android development any examples would be highly grateful.

What I believe you are trying to ask is how to subscribe your application to intents for launching web URIs. In order to do so, you can add an intent filter to your application's manifest.
There's an example of this on Lars Vogel's blog. It boils down to this:
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".BrowserActivitiy"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http"/>
</intent-filter>
</activity>
</application>

Related

Deep linking working with adb, not in browser

I have setup deep linking in my app previously and had it work just fine. All the sudden it stops working. I have the below manifest...
<activity
android:name=".MainActivity"
android:launchMode="singleTask"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
<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="https"
android:host="www.giftwizit.com" />
</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="giftwi" android:host="Products" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
When I attempt to load https://www.giftwizit.com in a browser such as Chrome or even Samsung internet it simply loads up a google search page. The same happens when I attempt giftwi://Products.
What's interesting to me is when I run the adb command like...
all is good... the launcher shows up and asks which app I'd like to open the link with.
Now I am using app-auth, and I know that it has me make this entry into the build.gradle file, but I've had this before and had everything work just fine.
This snippet is from within the defaultConfig inside the build.gradle file, and is how the react-native-app-auth documentation says it should be. I just thought I'd include this to be as transparent as possible.
Hoping to get some help on this. I have noticed at least one other post where some guy was having the same problem years ago, but it hasn't received any answers.
The reason for not able to redirect while typing/pasting URL in your browser is due to a bug in Chrome browser itself. but that turned out to be an functionality and adopted by some other browsers as well
You can check the bug here, and look at the status: WontFix (Closed).
Now the reason behind all this according to them,
If a user typing/pasting URL in browser then the user really want to go that URL, instead being redirected on a application
So your deep linking is working fine, best way to test it, share the link and then click on it
And also this always redirection really caused problem as well, when user was not able to go on the website due to redirection, you can also check a bug report here due to this always redirection, status is now Fixed (Closed) for it

Is there any way to know whether an Android App Link will open an app or not?

Is there a programmatic way to know whether a HTTPS URL will open an Android app using Android App Links?
For Universal Links, the iOS equivalent of App Links, one has the ability to use the static let universalLinksOnly: UIApplication.OpenExternalURLOptionsKey (documented here), when linking out to make sure that a URL will open an app or not. Is there an Android App Links equivalent for this?
<activity
android:name=".ui.activity.TestActivity"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<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="testapp"
android:host="host1"
android:path="/path1"
android:port="8080" />
</intent-filter>
</activity>
Then:
Open from App
Among them, scheme and host are required, and other requirements depend on your actual needs.

Voice Action Activity

Although I'm using Xamarin, I believe this to be a general Android development question. I'm developing an app, let's say "My App," that I'd like to be launched via the launcher and via voice using "Ok Google, start My App."
What I'd like to accomplish is to start MainActivity or VoiceActivity depending on the mode in which my app is launched. I found this blog post https://blog.xamarin.com/add-a-conversation-to-your-android-app-with-voice-interactions/ by James Montemagno but whenever I activate My App via "OK Google" it always starts at MainActivity.
I'm hoping someone can provide pointers on what intent-filters to add in order to accomplish this. Here's what I have so far:
<activity android:icon="#drawable/icon" android:label="My App" android:name="md593b8d625023f6802361dd1b8a6546be5.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="My App" android:name="md593b8d625023f6802361dd1b8a6546be5.VoiceActivity">
<intent-filter>
<action android:name="android.intent.action.VOICE_COMMAND" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE" />
</intent-filter>
</activity>
I've also read older documentation/reports of apps needing to be made publicly available in the Google Play store to be indexed before "Ok Google" works correctly, but it's not clear if those are for custom actions or something as simple as launching an app via voice.
Thanks in advance for any insight you can provide, I've been banging my head trying to figure out what should be seemingly very easy...
Thanks,
Ryan

Put my app in the Google Now Phone search list (Android Global Search)

I want to make my app searchable in the Google Now quick search box. I followed some examples but it still doesn't work. The official doc isn't clear at all about how to make this case work.
Now after checking these stackoverflow issues, I start wondering if this feature is still available to the developer?
Is global search in android still available for developer?
How do I get my app to appear in Google Now's Phone Search list?
I do see a few apps still make into the "Phone search" list in the quick search box settings. If so, anyone can shed some light for me? My searchable config xml is as follows
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="#string/app_name"
android:hint="#string/search_hint"
android:searchSuggestAuthority="#string/search_authority"
android:searchSuggestIntentAction="android.intent.action.VIEW"
android:searchSuggestIntentData="content://some_search_authority"
android:includeInGlobalSearch="true">
</searchable>
In this AndroidManifest.xml file, I do have meta-data specified for the SearchableActivity e.g.
<activity ...>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>
It's not possible (at least, yet).
Google Music has a Google Now card and to have something similar, you need to create your own.
Unfortunately, it has no public API yet: Google Now integrations
Now cards from apps are currently under development and are not available to all apps. We'll let you know when we are able to onboard more partners.
What you can do is to add your app into the list of suggestion for command "Play (Band name) (Song name)":
To make this happen, you have to add intent-fiters to your Activity, which should be opened to AndroidManifest:
<activity
android:name=".MusicActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
You can check out list of Google Now voice commands here: A list of all the Google Now voice commands
I hope, it helps

Intent filters not working to open custom app

I'm trying to get a URL to open up a custom application that I've written but the intent filters don't seem to be working. I've looked at a dozen or so threads in SO that seem to offer the "solution" but for me it's no good.
I need to have the action from a QR code scan open up my app. Therefore, I'm not inside any browser clicking any links. I'm simply opening my QR scanner, scanning a QR code, and wanting that to fire up my app instead of opening up the default Web browser. The default action for the QR Scanner is to open up the URI in the web browser.
The manifest.xml is this:
<activity
android:name=".Main"
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>
<data android:scheme="http" android:host="tinysb.com" android:path="/ecard/" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
My QR code points to http://tinysb.com/ecard/ so I'm looking for something to start up my app instead of the browser if that link is encountered by any application. Currently, the browser starts up and I'm not even given the option of what to do once I scan the QR code. For now, I'm not passing anything from the Web server, so I just need it to start up my app without passing anything into it.
Since this is all initiated from the QR scanner, there's no activity I can code to intercept the URI.
Many posts have said that setting up the android:scheme per above should do the trick, but it's not working for me at all.
Any help would be much appreciated.
The problem might be the QR Code scanner you are using. An application can appoint an Application to open the url instead of letting the android intent chooser handle it. Do you have several browser installed and are you prompted to choose one of them?
The following intent filter is 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:host="getamen.com" android:scheme="http" android:pathPrefix="/topics"/>
</intent-filter>
You could try using android:pathPrefix="/ecard" or adding the BROWSABLE category.

Categories

Resources