I am not able to use localhost with xamarin.android application.
I have executed Web project & Service project(not mobile app) on Chrome Browser.
The displayed port number I tried browsing in Android Studio emulators & Genymotion emulators by appending 10.0.2.2: & 10.0.3.2: respectively, I got result Bad Request-Invalid Hostname. Even I have tried Service project port number, both not working.
Web Project: ASP.NET project using Visual Studio 2017 & Having service project in the same solution.
Open your solution folder. You might have several projects inside 1 folder, you don't need project's folder but the root one. Inside you'd have .vs/config/applicationhost.config file, open it.
find <sites> inside you'll have sites that you are running, might have several, if you switch startup projects in one solution. The name will be corresponding to one displayed by IIS in taskbar when you right-click it's icon. The tag could be, for example, <site name="ServerApp" id="2">.
Now you need to add a line to bind external connections to your machine ip, for example
<site name="ServerApp" id="2">
...
<bindings>
...
<binding protocol="http" bindingInformation="*:60424:127.0.0.1" />
</bindings>
</site>
Set appropriate port number and protocol, what matters here is just map them to 127.0.0.1, not "localhost" then they will be available for android emulator via 10.0.2.2:60424 (the port number 60424 is just from the example above, use yours)
You can use our free extension Conveyor https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
If the IP that Conveyor gives you doesn't work, just substitute it with 10.0.2.2. Using Conveyor solves the problem of needing to make IIS Express bind to other hostnames. It also has some other features too.
I have solved this issue from third party software ngrock
Check this Android emulator not connecting to localhost api
A shoutout to the Top answer for putting me on the right track. In my configuration I certainly needed to change the binding to 127.0.0.1 instead of localhost in the solution config file.
Since I'm using Rider, the config file was in a different location. Check it out:
Under run/debug configurations, click the link open in editor next to (a checked by default) Generate applicationhost.config. This opens up the config file for editing.
In addition to the above, I also had to update the applicationUrl property in that same project's launchsettings.json file to use the loopback IP instead of localhost:
Restarting the service (and afterward the client) should go without saying, but one can never be too careful.
Related
I have been developing a website for a project targeting mobile phones and tablets, currently focusing on using the chrome browser. Much of this development has been done on one phone using a laptop. I had been using the "chrome://inspect/#devices" quite painlessly until I came to test on a different phone, when clicking "inspect" resulted in a white page. The problem seemed to be that as I happened to have no network connection at the time, chrome couldn't access some repository and so didnt load the page. After chrome visited this page, I no longer needed an internet connection to inspect my phone.
My problem is that now I have to migrate my project onto a computer which sits behind a firewall (which I have no access to) which is stopping navigation to the "chrome-devtools-appspot" link to pull whatever it needs to generate the page when I click on "inspect".
Is there a way to somehow download this repository and make it available locally on the machine so that regardless of what phone / browser version I use, the inspect page does not depend on an internet connection?
Its all about the Cache. When you chrome://inspect and click on "Inspect" the window requests the inspector tools from some google URL (looks something like this: chrome-devtools://devtools/bundled/inspector.html?isSharedWorker=true&remoteBase=https://chrome-devtools-frontend.appspot.com/serve_file/#f87f641eOabefed98578934of1d5ca79651bf82/&dockSide=undocked).
The solution is to do that first fetch on environment with internet connection, then copy the cache files of google chrome and paste them on the standalone environment.
These cache file are located on AppData/Local/Google/Chrome/User Data/Default/Cache.
I did the following and it worked:
On the machine with the internet connection:
Clean Chrome Cache (with 3rd app like CCleaner or just manually delete all files on Cache folder)
Open Emulator and open dummy app or chrome tab
Open Chrome then redirect to chrome://inspect then inspect the device.
Wait for it to load (to downalod the needed files) see new files on Cache folder.
Close Chrome.
At that point you can ZIP the Cache folder.
On the not- connected machine go to the Chrome Cache folder (listed above for windows users) & extract the Zip file there.
That's it you can now use the inspect without it fetching the files.
Again it did work for me, I am not sure if it has anythign to do with the SDK running on the emulator (IE Android 6/7 etc, maybe you need diffrent cache for each).
Hope it helps.
EDIT: It does have to do with Chrome, for each version of the browser the cache files needed are different. After some research the numbers after the # tag is just a commit number from google-chrome-repository. So, to clarify, The chrome tab you open on the device (mentioned above) must be same as the target you are trying to imitate. Meaning that is doesn't meter which android version you are using but which chrome APK you are using. You can just download Chrome APK to the version you need. The version you need is what is written on chrome://inspet.
Excuse me?
I pushed the file 'proxy.pac' to sdcard using this command:
adb push C:\Users\zuokang.li\Documents\proxy.pac /sdcard/
I try to set proxy auto config in android. So I set pac url "file:///sdcard/proxy.pac".But it cannot work.
I don't know whether it is set right. Can you help me ? Thanks!
Apparently Android doesn’t accept setting a local PAC file (127.0.0.1 doesn't seem to work either) and may even cause browser crashes for an invalid proxy port (-1). Therefore either
Use http://some_host/proxy.pac and store the file on some host, or
Use Firefox for Android and the exact same settings you used above (verified) - see https://www.topbug.net/blog/2015/03/02/configure-proxy-using-pac-files-on-firefox-for-android/ for info.
I experienced the same issue with my android phone, and searching for a solution I noted that the only one is to access to a web server for getting the .pac file (as Roy explains). But I wanted the solution (all about this) locally in my phone.
I installed a thin web server in my phone called SimpleHttpServer from Google Play and proceed as you do to set the .pac file using the URL provided by the web server (previously, I created a directory, located the .pac file inside it and pointed the web server root folder to that directory).
Additionally, I installed Simple Text Editor for .pac file edition and everything works as expected.
For use a PAC file in Android you can use Drony, looks ugly, but works! Even if you need authentication.
https://play.google.com/store/apps/details?id=org.sandroproxy.drony
Since file:/// is disabled on Android, you can convert the pac file to base64 and use this format:
data:application/x-ns-proxy-autoconfig;base64,
I want to send email from terminal android application. Is there any command for this or any email functions?
I, too, want to be able to send emails from terminal/shell scripts in Android. It took me over a week to figure out how to do it. Obstacles included:
Android's default command line toolbox doesn't offer this functionality
The busybox (v1.22.1 bionic) on my android device (MotoG with CyanogenMod 11) seems to have been compiled without the sendmail applet (!?)
Judging from the fact that I was not able to find an answer to your question anywhere, it seems that not many people seem to care about this functionality
I finally did find a simple solution: curl. It is dead-simple to get it working, but only if you have root access to your device. Here's how to set it up:
A. On your computer (desktop or laptop):
Download the curl package for android available here: http://curl.haxx.se/download.html (scroll down until you find the version for android)
Extract the package's contents using your preferred application
B. Use USB cable to plug your android device into your computer
C. Copy the curl binary from your computer (/data/local/bin/curl in the extracted package) to somewhere in your android device's PATH (I copied it into the /system/xbin directory) and make sure that the file is executable
D. Disconnect device from your computer and happy emailing!
Now you can use curl at the command line (or in your shell scripts) to send emails. Usage example is here: Using curl to send email. You can even send text messages! (see here: http://osxdaily.com/2014/03/12/send-sms-text-message-from-command-line/)
This is regarding HTML5 offline apps on Android devices.
We are running into an issue where bookmarking an offline capable HTML5 app (with a complete cache manifest file) fails to load on the Android browser under the following conditions:
Bookmark the app on the browser
Switch off all wireless connectivity
Close the browser completely
Attempt to launch the bookmark from the homescreen
We end up with an "Unable to connect to the internet" message. The app works perfectly fine on iOS devices when saved to homescreen and on airplane mode.
Is there a specific way the app should be saved, or is this an Android specific quirk?
I'd check and see that:
MIME type really is text/cache-manifest.
Your cache-manifest starts with CACHE MANIFEST, your urls thereafter are either relative to the manifest or absolute URLs.
You don't have any broken links in your manifest, or a forced NETWORK: tag.
So, I had faced similar issues with chrome and android on multiple instances. Apparently there is no issue with the implementation because I tried it on FF and it worked just fine, and the same was true about safari. The only thing I presume this is caused by is, the data is getting cache for the web page on the RAM when chrome is running. If you close the browser, and android ends the process a fresh instance of chrome is initialized and your existing app data is gone. I cannot confirm this, but it seems very likely that it might be the issue.
Also check your server is configured to send the mime type correctly: How to set up your server to send the correct MIME types
What's the file name of your cache manifest? I have heard that the extension could affect android's behavior. Make sure your file ends with .manifest
In addition, make sure your server is correctly serving the MIME type for manifest files, which is text/cache-manifest
In addition to Ben Max Rubinstein's and Compid's answer, if your app url is something like this: example.com/myapp you need to add a following forward slash, like this: example.com/myapp/.
When you are online the server will redirect you automatically, but if your are offline obviously that cannot happen.
What I encountered was that the .manifest files in Apache's mime.types configuration was correctly set to text/cache-manifest and then several lines below was overwritten as application/x-ms-application (for compatibility with MS' ClickOnce thing). To resolve this I've taken different file name ending, namely .cachemanifest, configured correctly its mime type, restarted Apache, renamed manifest file as cache.cachemanifest, changed my <html> manifest attribute to point to this file, and then I was finally able to cache my web app on Android (there wasn't any problem in desktop browsers which apparently don't care about the mime type of cache manifest file). Hope this helps.
I need to work on android gingerbread sourcecode. I have linux (ubuntu) but no internet connection. My friend is already having the sourcecode downloaded to his system(ubuntu) from internet. Is it possible to copy and paste the code from his sytem to mine with out any issues running it? If it is possible, please specify the file paths if you know.
There should be no problems when copying source code from one machine to the other. No paths should be specified, it should work fine as is.
Both getting code from remote location via network or copying it form another machine are conceptually equivalent. After all both are just "copying" data to you computer.