Phonegap 2.6 android inappbrowser opens on self despite _blank being passed - android

I am using PhoneGap 2.6.0 with Sencha Touch 2.2 on Android 4.0.3. I am calling the InAppBrowser to open a share url to facebook like so:
window.open(encodeURI('https://www.facebook.com/sharer/sharer.php?u=http://www.mycoolapp.com/&t=Everyone check this out'), '_blank', 'location=no');
However, instead of opening the InAppBrowser with the UI, it opens on top of my app screen without any 'OK' button like on iOS or any way to close and go back.
I am able to go back with the standard Android OS back button.
Is there any way to get the url bar and the OK button to show on the Android InAppBrowser for PhoneGap?

As per window.open section in docs, you have to give `location=yes' to show location bar. Regarding type of window, do you see any difference when you pass '_self' and '_blank'?

Maybe a problem with your Access-origin in res/xml/config.xml (PhoneGap 2.6.0 Domain Whitelist Guide)...?

As others stated, for android you have to specify location=yes and no you can't get riddle of the location bar and mantain back button.
But if you are on Android why do you have to keep it?
Being able to coming back with physical back button is the preferred behaviour by design in Android.

Related

Disable Chrome Options Menu - Android

I am trying to do SSO using Chrome Tabs in my Android Application.
Whenever the chrome comes in it also has options menu of chrome - Is there a way to disable this options menu.
Attached is a screenshot
No, currently is not possibile: you can add items but not remove the button.
https://developer.chrome.com/multidevice/android/customtabs
Simply use a WebView instead of CustomTabs - then there is nothing to hide away, to begin with.
In cases like this you should use phonegap instead of use chrome browser as webview read the docs
basically it runs chrome webview on android, and safari webview on IOS but without all chrome/safari options.
Hey there so in my opinion you should use simple Android webview if you don't want your user to access these options.
Just create a new activity/fragment that contains webview and open your website or any url within it.
This might help you from android developer docs.
Also try this example that might be useful.

Add native functionality to hybrid apps

We have an Ionic app where we want to add a new feature in native. So clicking a button in the app, will launch a plugin just like normal plugins with it on UI etc. However complication comes when I want to navigate freely back and forth from plugin side to Ionic.
Consider these scenarios:
Plugin to open a HTML page written on Ionic side based on a user
action. Clicking back on this html page will again land you back to plugin UI.
Maintaining back stack in Ionic and Android/iOS side so that back navigation happens smoothly.
What I did so far is to use sendPluginResult method to pass different codes to Ionic side and open desired pages. In reality it destroys the back stack totally since plugin has exited.
Clicking back button on Ionic side, I actually make plugin method calls again kind of emulating back behavior.
Is there a better way to handle this? Has someone faced similar problems?
I hope that I understood your question correctly.
Assuming that you can use some variable to check whether this plugin just opened a html-page, you could do something like this:
$ionicPlatform.registerBackButtonAction(function(event) {
if(/* check if plugin just opened html-page here */){
// if condition succeeds, then do not open same html-page again
event.preventDefault();
// go two steps backwards to prevent this plugin to open same html-page again
history.go(-2);
// update your variable
// ...
}
},100);
Hope it helps.

Is there any way to avoid this screen while accessing "mailto:"?

I am trying to use mailto link in my app but when clicking that link, I am getting a screen saying
"Webpage not available and some error", although email application
opens properly but I want to bypass that background error page.
Please note that I am using following code inside the button click:
window.open('mailto:alok1141#gmail.com?subject=Feedback: Competitive Aptitude');
Please suggest any way to avoid this background page.
Image with background error screen
My best guess is that you need to use a link <a href="mailto:..."> instead of a button or maybe use window.location=... in the onClick so that the browser can present the popup directly.
Now you tell the browser to open a window with the mailto url so only after the window has been opened it will check the url and present the popup.
There's two kind of format "mailto:" or "message/rfc822" MIME type. You have to add it on Intent with setType() If no app supports both, then it will shows the default chooser.
Have you tried setting the target to _system? It could be that your app is attempting to handle the link itself and failing. By setting the target to _system, you are asking the OS to open it for you.
window.open('mailto:alok1141#gmail.com?subject=Feedback: Competitive Aptitude', '_system');
You will also need the inappbrowser plugin. This plugin ensures that adding _system actually works. I believe on Android you may not need this, but you definitely will for iOS.
cordova plugin add cordova-plugin-inappbrowser
Thanks,
I found the solution. Actually when you run the application in phonegap app it will not open href="mailto: xyz#email.com" thats why I had to use window.open,
but once you will build the app even href="mailto: xyz#email.com" will work and best thing is it will directly open the app and no background error page will appear.

Apache Cordova InAppBrowser shows keyboard and hides it immediatly

I've got an Cordova PhoneGap application, that is loading the Google Authorisation page. If I click on an input field, the keyboard shows up for about 300ms and then closes instantly. What have I done wrong? I open the InAppBrowser in the following way:
this.popup = window.open( c_encode(self.providerURLs[provider]), "_blank",
"EnableViewPortScale=yes,location=yes" );
Best Regards
Daniel Gruber
Do you use the executeScript functionality of the inappbrowser plugin? Maybe even an interval?
This would close the keyboard on older devices, see this bug:
https://issues.apache.org/jira/browse/CB-5449

in Cordova 1.8.1 - Android history.back() not working

I am developing a phonegap application in which the app loads the external url(http://example.com) into webview. When I navigate through the screen using window.location.href. I cant able to go back to the previous screen using the soft back button that present in the webview itself.
The android hard back button closes the back(which is fine for now).
Can anyone help me out.
It is the same problem: If jquery mobile does not create history entries, the back-button from the android phone will terminate the app, because, there is no Activity to go back to.
If you go forwrd through your app, make a pushState: https://developer.mozilla.org/en-US/docs/DOM/Manipulating_the_browser_history
If you have history entries, your app will not close and hopefully the soft-back button will work.

Categories

Resources