I am creating an app in which I want that when the
user clicks on Banner ad,(Normally it opens the default browser to handle the redirect process)
Instead of this,
It will not open any browser and only copy the link which is sent to default browser and open it inside my web view.
I want to get the URL from the banner ad.
I had searched on google for it but unfortunately, I did not find anything useful.
Thank you all of you for my help in advance...:-)
This is against the terms of service of your adMob i guess. You can't access the url and open it yourself in webview. But i can suggest you to create your own activity and make it default browser in manifest. I think that will work for you.
Here is example how to do it.
add these filters inside <activity></activity> of your webview activity
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
Hope this will help you.
Related
I want to open my app and load the URL when specific links are clicked.
This is my Manifest for handling external links.
<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:scheme="http" android:host="www.android.com" />
<data android:scheme="https" android:host="www.android.com" />
</intent-filter>
And for handling incoming links this is the code
intentData = getIntent().getData();
if(intentData !=null){
loadUrl = intentData.toString();
}else {
loadUrl = "https://www.android.com";
}
webView.loadUrl(loadUrl);
Now when I clicked https://www.android.com from external app like whatsapp its loaded in webview but the webview is attached to whatsapp. Check screenshots below.
And if anyone can give me any hints or guide me on how to open my app when I open the URL(https://www.android.com) from Google Chrome(in my phone) will be a great help
For second part of your question:
And if anyone can give me any hints or guide me on how to open my app
when I open the URL(https://www.android.com) from Google Chrome(in my
phone) will be a great help
take a look at this answer:
"Essentially, the Chrome team feels that if a user actually types something into the address bar, no redirect should ever happen. As you've discovered, this is counter to behavior in all other browsers."
Use this line in Manifest file of your Activity which is Handling that intent to avoid such problem.
android:launchMode="singleTask"
You can find detail implementation here, https://developer.android.com/guide/webapps/webview.html
You have to override methods, and handle clicks.
I am trying to implement a new feature for my android application.
scenario :
when some event occurs, the camera sends an email to my (Gmail) account.
on opening the mail, it will have a link (html).
when user clicks on that link, it should launch my application Home activity.
I need to understand :
how to create that html link.
how can i make the link to launch my application Home activity.
kindly help me to understand what all things i need to do in my application.
I used "Blackbelt's" user comment and i was able to get the intent html link working.
But my problem is : i want to use a custom scheme "mobile" instead of "http"
I am using Gmail to use the link. But when i send using custom scheme. Gmail doesnt recogonise as hyperlink. So i cannot click on the link.
Please help me how to use a custom scheme. with gmail
you need to register an intent-filter for your Activity on the AndroidManifest.xml file, defining a custom url. . E.g.
<activity android:name="path.to.YourActivity" >
<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="it.is.my.app" />
</intent-filter>
</activity>
So if you press on a link like https://it.is.my.app, you should be prompted with the android intent chooser, with your app
I'm actually using Crosswalk.
I have some hard restrictions about speaking about my project so i'll try to be as clear as possible.
When I open my app manually, Webview load the home index.html of the website.
But this website is used for WebRTC so, it send an invitation via an e-mail with specific URL.
Is that possible to open my own application with URL that I just clicked ?
I checked for some <intent-filter> but I have no clue how to deal with the URL opening.
Hope someone have some solutions or clues.
EDIT:
<intent-filter>
<data android:scheme="https" android:host="xxx.xxx.com"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
With that I can open my application when I click on a link, but I still need to get the link url and set it as url loaded in my XWalkView.
Example:
https://xxx.xxx.com/join?xertfgf=1
When I click on that, my app open good, but know i want my XWalkView to load this.
Help :c
Problem solved:
After setting <intent-filter> correclty, if you use Crosswalk ( it will work with classic or Cordova Webview ) just :
Intent intent = getIntent();
String link = intent.getDataString();
xWalkWebView.clearCache(true);
if(link!=null){
xWalkWebView.load(link, null);
} else {
xWalkWebView.load("file:///android_asset/index.html", null);
}
I have two applications, AppOne and AppTwo.
AppOne is a simple app which exports an Activity so that it can be launched from a webpage with following 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:host="what should be the host for a local page?"
android:scheme="what should be the scheme?" />
</intent-filter>
AppTwo contains an activity which has a WebView. In WebView, I am loading a local html page, index.html with following href
launch app
Specifically, I want to know
What should be the host name for a page loaded locally?
What should be the scheme as per the scenario?
Thanks
The scheme can be anything you want it to be - so choose a word that means something to your app such as "apptwo".
If your scheme is unique, then you don't need to specify the host in the data part of the intent filter. If you are simply using the link as a trigger (ie. you always load the same page index.htm), then it doesn't matter what the rest of the URL is.
In AppTwo, you then simply have to arrange to load the relevant file into the webview when the intent fires.
<a href="apptwo://trigger">launch app</a>
My WebView application loads a html file and display it. Now how do I register it as a default HTML Reader in the Android system?
Meaning for example now if I click on an html attachment in email it shows "Complete Action using", then lists the HTML Readers in the Android system. How do I register my application to be one of them listed?
Must I modify my code to allow this? Currently my application is just loading a html attachment from the sdcard.
Thanks In Advance,
Perumal
This will do the trick:
<activity android:name=".YourBrowserActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
</intent-filter>
</activity>
Replace YourBrowserActivity with the name of your activity class. Call getData() on getIntent() to receive the URL or the requested page.
This will not replace the browser, however. If you tap on the earth symbol on the bottom of the home screen, this will not open your browser.