Like a parental control application, I have bloacked few websites. As the blocked url is detected its re-directed to about:blank.
Evey thing is working fine, problem arises in Android 4.4 Chrome browser.
about:blank opens in new tab, along with recentaly open tabs.
I want the close all thoes tab. Below is what i have done.
Intent mBrowserIntent = new Intent(Intent.ACTION_VIEW);
mBrowserIntent.setPackage(packageName);
mBrowserIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
mBrowserIntent.putExtra(Browser.EXTRA_APPLICATION_ID , packageName);
Uri uri = Uri.parse(defaultURL);
mBrowserIntent.setData(uri);
startActivity(mBrowserIntent);
Related
Since Android 12, links can only be opened with one "approved" app.
As of right now I have my app's supported urls defined in AndroidManifest.xml as intent-filter.
Also I have a button in my app that creates an intent to open a link in browser.
With Android 12 limitations though, if I have the url tied to my app, clicking the open in browser button does re-open my app, which is quite an unwanted behavior.
Is there a way to force a url open in chrome (or other browser)?
I checked the android developer documentation but have not found anything about it.
Thank you
You can specify the default browser explicitly as the package to handle your intent:
val defaultBrowserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("http://"))
// This would be Chrome if it's the selected default browser
val defaultBrowserPackageName = packageManager.resolveActivity(
defaultBrowserIntent,
PackageManager.MATCH_DEFAULT_ONLY
)
?.activityInfo
?.packageName
val yourIntent = Intent(context, ...).apply {
package = defaultBrowserPackageName
}
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
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"
I am getting an issue while opening URL in my default browser (Chrome)
My requirement is opening URL in the last open tab in Chrome browser for 4.4.4 (Chrome is default browser). NOT in a new tab.
Below code is opening URL in a new tab:
Intent mBrowserIntent = new Intent(Intent.ACTION_VIEW);
mBrowserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); mBrowserIntent.putExtra(Browser.EXTRA_APPLICATION_ID,mContext.getPackageName()); mBrowserIntent.addCategory(Intent.CATEGORY_BROWSABLE);
mBrowserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mBrowserIntent.setData(Uri.parse(mUrl));
mContext.startActivity(mBrowserIntent);
Please help in resolving this issue.
Thanks,
This works for me, note that you should not use getPackageName():
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://yahoo.com"));
intent.putExtra(Browser.EXTRA_APPLICATION_ID, "com.android.browser");
startActivty(intent);
EDIT: I just tested it on 4.2.2, and it works.
Expected Result
To open a webpage in external built-in browser (not popup window) when clicking a link in a web view.
Problem
When Popup Browser is enabled in Samsung Galaxy Note II (GT-N7100), the web page is opened in the Popup Browser, and I don't want this. I want the web page to be opened in external built-in browser even if the Popup Browser is enabled.
The setting of Popup Browser in the Samsung Note II can be found at Settings -> Application manager -> ALL -> Popup Browser.
IDE
Android version = 4.1.1
Device = Samsung Galaxy Note II (GT-N7100)
Code
public class PeppermintWebViewClient extends WebViewClient {
//....
private void handleOpenBrowserScheme(String url){
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse(url);
intent.setData(uri);
mainActivityInstance.startActivity(intent);
}
}
I don't understand your problem clearly but may this help you:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse((String) i.getExtras().get("url")));
startActivity(browserIntent);
where "url" is the URL to which you want to go in your browser.
And i is an INTENT that holds the "url" from another activity.
Can this help you?