Web intent url getting modifying automatically - android

I trying to a webpage link so for this I am using following code
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://example.com/privacy"));
startActivity(browserIntent);
when I click on link, it open in web browser and go to proper page, when i press again on app link and open it again web browser its URL get modifying automatically, on second click i get URL like this
"https://http//example.com/privacy" I don't why this is happening

I find bug in my code
my string file had anchor tag attached thats why new url getting added to intent
this ling had bug
<string name="txt_terms_and_conditions"><a href='https://http://example.com/privacy'>By clicking the Send OTP option,\n you agree to our Terms and Conditions</a></string>
so I removed anchor tag so it working normally

Related

Can't open link like "intent://" in android app

I want to open link like "intent://qr.nspk.ru/url-something/#Intent;scheme=someScheme;package=com.example.android;end#Intent;scheme=someScheme;end" from an android application.
If I write something like this:
val i = Intent(Intent.ACTION_VIEW, Uri.parse(androidUrl))
startActivity(i)
I get this error:
No Activity found to handle Intent { act=android.intent.action.VIEW
dat=intent://qr.nspk.ru/url-something/#Intent;scheme=someScheme;package=com.example.android;end#Intent;scheme=someScheme;end
But If I go to this link from browser, it opens and it open an app that I need. Can you help me to understand why I can't open link from app and how to fix it?
The intent: scheme is used for the browser to encode an Android Intent. If you want to use this URL from an Android app, you need to create an Intent from the URL like this:
val i = Intent.parseUri(androidUrl, Intent.URI_INTENT_SCHEME)
startActivity(i)

Chrome RE-DIRECT without Opening New Window or Tab

Need to get Chrome to RE-DIRECT in the CURRENT TAB-WINDOW and NOT OPEN a New Tab-Window for the URL Re-Direct.
Any clues?
The Code - but opens the RE-DIRECT URL in another Tab-Window:
Private Chrome As Intent
Chrome.Initialize(Chrome.ACTION_VIEW,"http://www.youtube.com")
Chrome.SetComponent("com.android.chrome/com.google.android.apps.chrome.Main")
StartActivity(Chrome)
I have an idea!!!
Is there ANY WAY to CLOSE CURRENT TAB? So nevermind Chrome opens New Tab.
A standard way of redirecting the page using Javascript is by changing window.location:
window.location="http://example.com"

How to view HTML file from application data on Chrome Browser in android

I'm doing Android application which I want to open an HTML file from my application data on Chrome browser without manual interrupt. Currently it's working fine for default browser.But I want to open it on chrome browser.
My Code for default browser:
Intent browserIntent = new Intent(Intent.ACTION_VIEW);
browserIntent.setData(Uri.fromFile(file));
browserIntent.setType("text/html");
browserIntent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
browserIntent.addCategory(Intent.CATEGORY_BROWSABLE);
browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
browserIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivity(browserIntent);
How could I proceed that on Chrome browser explicitly.If I tried like setClassName("com.android.chrome", "com.android.chrome.Main"), I'm getting exception as
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW..." .
Please help me to get out this issue. Is there any other way?Thanks.
Set classname as
com.android.chrome/com.google.android.apps.chrome.Main
browserIntent.setClassName("com.android.browser", "com.android.chrome/com.google.android.apps.chrome.Main");

Play Video on the Browser

I tried to open the video from url with Intent.ACTION_VIEW, and it was successful.
But, the problem is, after the browser appeared for a second and it's automatically minimize and the front is the activity on the apps.
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = Uri.parse("the url of the video with format .m3u8");
intent.setData(data);
startActivity(intent);
I'm expecting exactly the same way when i put the URL into the browser manually, but without minimize the browser when it has already been launched.
Need some flags? grateful for any response and suggestions.
I bet that the browser is just quitting as a result of an inability to display the content. If you plug in the video url to the browser manually, does it work? What is the filetype of the content you are trying to display?
Have you tried explicitly setting data type by using setDataAndType(Uri data, String type) where mime type is "audio/x-mpegurl" (the full mime type is "audio/x-mpegurl; charset=UTF-8"). You might have some switch statement to check URL user has clicked to force type in case link points to ".m3u8".

Android - Call default browser with and redirect to a designated url

Hi
I want to write an app to call default browser and redirect to a designated url.
Any suggestion to 1)call the default browser, 2)redirect to a designated url.
Thanks
you just want to launch an ACTION_VIEW intent with the Uri of the webpage as your data element :
Intent httpIntent = new Intent(Intent.ACTION_VIEW);
httpIntent.setData(Uri.parse("http://www.bbc.co.uk"));
startActivity(httpIntent);
To open the default browser use an Intent with the action VIEW. To tell the browser which page to load us the data-part of the Intent.
Example:
Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse("http://stackoverflow.com"));
startActivity(browse);
Since this is a basic task in Android you might want to read some basics about Intents in Android.

Categories

Resources