I have created/published an app to Google Play using the Phonegap framework and Eclipse. My question most likely has a simple answer, but after some unsuccessful research, I've reached an impasse. There are a few iframes that are supposed to access SoundCloud mp3 files online. The sound files are displaying (thus accessing the internet), but they will not play any music, rather once you click the play button, the iframe changes to a generic SoundCloud social media display. Additionally, there are a few links (target = _blank) that are still displaying within the app view rather than opening a browser window. This is a lesser issue for me, but I believe these two issues are inter-related, as I haven't really coded anything in Java except the necessary lines in onCreate in the Main Activity. Again, this app works, it's really just the nuances of debugging the internet access that I can't figure out. Here are some more salient pieces of information, and I thank you for your advice and feedback:
PhoneGap: Cordova 2.9
Permission: <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Main Activity:
public class MainActivity extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 3000);
}
}
You can use connection object (navigator.connection) to check for Internet connectivity.
Below is the link for further details-
http://docs.phonegap.com/en/2.9.0/cordova_connection_connection.md.html#Connection
If are you accessing it within i-frame you may need to use parent.window.navigator.connection
Related
I have here an Android device with a build in hardware barcode scanner module with a hardware scan button. I never developed an android app. but i checked the SDK of the device. The sample app uses a BroadcastReceiver to get the result of successful barcode scans.
private BroadcastReceiver mScanReceiver = new BroadcastReceiver() {
....
}
....
protected void onResume() {
super.onResume();
IntentFilter filter = new IntentFilter();
filter.addAction(SCAN_ACTION);
registerReceiver(mScanReceiver, filter);
}
Because i'm not familiar with java I don't want to develop an app to use this device. I want to use the scanner in chrome browser instead, to work with HTML5, pouchDB & javascript.
So my questions are:
Can I listen for such android Broadcasts in the chrome browser? (how?)
If this is not possible, i think about building a simple app which opens "Chrome Custom Tabs". Is it possible to pass messages from the app to its Chrome custom tabs?
Or is there another way to solve this?
For a little context, I am currently working on an irc client based off of the open source kiwiirc web app. I'm building it to be cross platform so I have been doing some preliminary testing just to simply load the kiwiirc.com client in a web view.
Nothing fancy, just load the page up in a webview, and log in to an IRC server. On iOS using the standard UIKit frameworks, and for Desktop using Qt I have had great success.
On android not so much...
For some reason unbeknownst to me the webview on Android refuses to load the content for the address https://kiwiirc.com/client
It will load https://kiwiirc.com/ just fine, and in fact it will load any other website just fine as well. The only URL I have an issue with is the core one I need access to.
I've been trying to solve this problem for a few days now, and figured I'd come to the stack overflow community for some help since I am out of ideas.
The following is my code that I am currently using:
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final WebView webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.setWebViewClient(new WebViewClient(){
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
webView.loadUrl("https://kiwiirc.com/client");
}
}
Here are the following things I have tried in the order I have tried them, as well as their results, while I have been troubleshooting this issue:
Enabling Javascript - no affect on loading the webpage
Enabling DomStorage - no affect on loading the webpage
Embedding KiwiIRC in iFrame on another webpage - will load the webpage and kiwi embed PERFECTLY, but unfortunately I cannot fetch data from the iframe due to the "Same Origin" security policy.
EDIT
Relevant note: https://kiwiirc.com/client loads correctly via the android google chrome browser, but not in the webview of my app.
If anyone can offer me tips on troubleshooting this issue, provide me with a solution, or point out some obviously trivial thing I forgot to do, that would be amazing.
Thanks!
I'm working on Rails app and I need to detect if I'm on Firefox private session using Javascript code or some JS plugin.
I'm testing on Firefox 43.
I was trying using Components.classes but this is undefined. The problem is like Firefox on private session uses Tracking protected, this is not loading some JS files and I need to know if I'm on private session (then Protected Tracking is enabled), and then, I'm not going to load this tracking JS files.
Thanks in advance.
I saw some posts to check if we are in private session on Chrome and Safari and these work well on these browsers but don't work on Firefox!
I believe that there is no truly reliable way to detect private browsing. That said, I've used this in the past, and it worked quite well for me!
Android 4.4.2
Cordova 3.4.1
jQuery 2.1.0
jQuery Mobile 1.4.2
I need to post my login credentials to a server (IBM Domino 9.01 in this case, but it's irrelevant) and the server responds with a session cookie, among other things.
This works great on iOS, but I don't get any cookies what so ever using my Cordova/Phonegap app on Android. I see this using Chrome Dev Tools. I know that Android gets the cookie because I'm logged in and can browse around. But it doesn't seem to trickle down to the WebView where my JavaScript code lives.
I have modified my appName.java file:
import android.os.Bundle;
import android.webkit.CookieManager;
import org.apache.cordova.*;
public class Rooms extends CordovaActivity
{
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.init();
// Set by <content src="index.html" /> in config.xml
CookieManager.setAcceptFileSchemeCookies(true); //available in android level 12
CookieManager.getInstance().setAcceptCookie(true); //available in android level 12
super.loadUrl(Config.getStartUrl());
//super.loadUrl("file:///android_asset/www/index.html");
}
}
I'm not 100% sure about this part:
CookieManager.getInstance().setAcceptCookie(true)
It compiles and runs fine, but I can't access any cookies.
I need access to the cookies because, to my knowledge, there's no other way to extract the NONCE value in a session on a IBM Domino server.
I don't think this works I tried it on my phonegap android application . The Best solution is to use localStorage or sessionStorage. Maybe you can try to use some other means of sending sessions like using tokens or sending them through headers... that's what i'm doing now..
also check this out
Handling cookies in PhoneGap/Cordova
I am developing a android app using phonegap, it calls a website (http://siteaddress.com:8081) to get json encoded data. This is working fine on the emulator, then I built the android package .apk file using phonegap build but when i installed this package on my android phone and started the app, it force closes the application showing the error "The connection to the server was unsuccessful.(file:///android_asset/www/index.html)".
I have built the app using phonegap build, passed it the index.html as well as tried the .zip file package but still getting this error. I tried searching for this error and also included the below code in my app as suggested on some sites but still it is giving error.
super.setBooleanProperty("loadInWebView", true);
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
Has this got something to do with the website that i am trying to call from my app? I tried opening that site in the mobile browser but it didn't opened but the website works fine on a desktop browser. Is there something wrong that i am doing?
I'm guessing its the port number your using. Have you tried using port 80 for your server rather than 8081? Its possible that port isn't open on your device.
The following code snippet solved my problem
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/home/index.html");
super.setIntegerProperty("loadUrlTimeoutValue", 10000);
I have added
super.setIntegerProperty("loadUrlTimeoutValue", 10000);
to the com.mypackage.xxx.java file
for 10 sec waiting time
*I had Same problem solved by referring * this link...
This error occurs bcoz of Server connection timeout so, Has mentioned in above post u can give 10 sec delay in that time put some splash screen..