[Q] WebView problem with loading images - Android Software Development

Hi,
I'm developing simple app that display images in WebView.
While coding i get problem with load data in WebView. When i try to load some data like:
Code:
String data = "<html><body><img src="http://xxxxxxxxxxx"/></body></html>"
WebView.loadData(data, "text/html", "utf-8");
the image can't be loaded because the link in src="" is redericting me to another page that contains not only image but full web page.
The example is: http://i1.kwejk.pl/site_media/obrazki/02491-77d715da62fe976.jpg
When i try to load this image it redirect me to that page: http://kwejk.pl/obrazek/02491
It's even working like that in Desktop Browser, Phone etc.
Is there any solution to disable redirecting to another page when loading image??
Please help.

Related

Auto updates of software - how to?

Hi,
I need auto update functionality for my application. I.e., the new exe/dll shall be downloaded by GPRS and existing program files shall be replaced. Now I wonder, how this could be done in an easy way.
The problem is, that the application is continuously running and updates shall be done more or less "on the fly". Currently, the application is automatically started on boot through registry settings in HKLM/init
So my idea was the following: Creating a "starter programme" for the application: When the device (HTC ARTEMIS) is booted, the starter programme is first launched (through HKLM/init), looks into a pre-defined directory if there are any files. If there are, these files are copied into the directory of the application. Afterwards, the starter programme launches the main application. Do you think that could work? Or are there any better ways (maybe even supported by the OS) to perform SW-updates?
Günther
I have auto update functionality in my commercial application.
1) When data is replicated to server, main appliation also check availability of new version. If new version is available a and upgrade is mandatory, application launch new process - updater.exe.
2) Updater waiting to main application correct exit (saving data on dirty forms etc.)
3) After main application exit updater download new version descriptor (list of files with targer location, install scripts (dll with well known special interface which can be used for many special tasks - create shortcuts, delete file, modify registry, install new certificate). Updater downloads all files, process install scripts and then launch main application again. New install CAB file is usually stored to extended ROM (autoinstall after HARD Reset).
As a server component is used web service with some methods (GetDescriptor, DownloadFile).
ma_gu said:
Hi,
I need auto update functionality for my application. I.e., the new exe/dll shall be downloaded by GPRS and existing program files shall be replaced. Now I wonder, how this could be done in an easy way.
The problem is, that the application is continuously running and updates shall be done more or less "on the fly". Currently, the application is automatically started on boot through registry settings in HKLM/init
So my idea was the following: Creating a "starter programme" for the application: When the device (HTC ARTEMIS) is booted, the starter programme is first launched (through HKLM/init), looks into a pre-defined directory if there are any files. If there are, these files are copied into the directory of the application. Afterwards, the starter programme launches the main application. Do you think that could work? Or are there any better ways (maybe even supported by the OS) to perform SW-updates?
Günther
Click to expand...
Click to collapse
Seems to be a good idea. This way, you can update the application while it's running and changes become active when the device is rebooted or the application is exited and started again. It's just excellent.
My needings were more simple, so the update feature I designed works as following:
1. The program is divided into a launcher, an updater library and the true application.
2. When the program is started, the launcher copy the update library call such a copy (just call it updlibcpy).
3. updlibcpy uses http to check if an update is available. The check is performed by downloading an "update manifest" containing the MD5 hash of each file of the updated application and checking it against the MD5 hashes of the current program files.
4. If one or more files need to be updated, updlibcpy does the task. Since only updated files are downloaded, no bandwidth is wasted. The only file that cannot be updated is the launcher, but it is so simple that it should never need an update.
5. When updlibcpy has ended, the control is passed back to the launcher, which invokes the true application executable.
The main difficulty was handling the high packet loss that the HTC devices I used has shown. This caused frequent application hang-ups during start-up, unless the GPRS connection was terminated and started again. Once I solved this problem by giving a timeout to the update (using threads), all worked perfectly.
The only improvement I'm thinking about is some sort of "transactionality" of the update, so that if one file updates correctly while another doesn't, the succesfully updated files roll back to the not updated version.

[Q] Flash Global Security Settings

Hello,
I'm trying to make an application that uses a webview to load a page containing a swf which should be populate with data loaded from a localfile.
The main idea, is that if I want to open that html from my computer directly, I should go to :
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
... and add the swf as a trusted file. If I copy the files inside tomcat, and start the tomcat, I can view thee swf with all data loaded
Now, in android I can't open that page to change the Global Security Settings, so I can't load the data. Do you have any idea how to do this? Or a workaround to this?
Ok, I see that no one has any idea.. But what about creating a tiny web server that returns that page? I think it should do the trick, but I can't find any tutorial about creating web servers in Android.. basically I need to open a port and return the html from @assets relative to what's after localhost : port. Do you know, or have a sample that I could use it as an example?

ImageView setting image not working on my particular device

I'm quite a beginner in the android world, so forgive me for any trivialities. I've developed a small android-app using Android-SDK and Eclipse-ADT that maintains information in an sqlite database. Now, there is a simple activity that reads product information from the sqlite db and updates the editbox controls. But one of the information is an image-location for that product (typically '/mnt/sdcard/something.jpg'). I use an ImageView control to display this image as described in the Android API:
img.setImageBitmap(BitmapFactory.decodeFile(c.getString(2)));
This works well on all android devices and emulators I've tested on, except one - on my particular device (Karbonn A30), the imageview is just blank, it doesn't show up anything!!
Hello,
I am facing the same issue on my ASUS device. On the emulated and Sony device it works fine.
To be sure that the file exists I have build in a Toast message that confirms that file exists on SD-card.
But the ImageView remain blank on the ASUS 300 TFT device.
Have you figured out what the issue is?
When I refer to an image on in the res-folder, then it is displayed.
Are you getting the image from SD card? If so, how are you retrieving the path to the image? Android devices vary greatly on how they handle external storage and their respective paths. What android version are the devices you're testing on?
______________________
Root it and boot it!
Current device: Sm-n900p/Sprint Note 3
ROM:AICP ROM
Service: Straight Talk
Check out my apps on Google Play
Hello,
I am using the android API's to access the pictures, like:
File externalDir = new File(Environment.getExternalStorageDirectory(), dir);
File mydir = this.getDir(dir, Context.MODE_PRIVATE);
I have tried it both for internal and external and external storage.
I have even build in a check to see if the image really exists (showing a positive result in a Toast-message).
I think it might be related to the size of the image.
If it is too big, would I need to resize it first to be able to display it?

Problems accessing a password protected website in an android webview

Hi,
i just wanted to write a short webview based app to view a password-protected webpage, so it is not accessable for everyone (without user/pw) from a usual browser. i use android-studio.
In a Browser i access the website by typing it's url and enter username and password in the upcoming pop-up window or by including the username/password into the url like:
<username>:<passwort @subdomain domain tld / folder /
when i used a WebView element trying to load an unprotected website it works fine in emulator and on the real device i've tested it on, but when i try to load a website that requires authetification it works fine on the emulator but doesn't work on my real devices.
My Samsung GT-i9305 shows me the "401 Authorization Required" page i get when i cancel the pop-up.
Code:
//inside onCreate
WebView aWebView = (WebView) findViewById(R.id.webview);
aWebView.loadUrl("http : // username : passwort @ subdomain . domain . tld / folder /"); // i hardcoded the username and pw in the url
i see, it doesn't authenticate using the user/pw-.information from the url.
how can i tell the webview to authenticate with given user/password
but i can't find an other way to tell the webview not to ignore the authentication.
i read to use the "onReceivedHttpAuthRequest (WebView view, HttpAuthHandler handler, String host, String realm)"
but don't know how to get a httpauthhandler that tells the webview to give prestored usernames.
am i stupid?
the developerpages from google can't really help me
has anyone done this before and found a working solution?
M;

[TRICK] How to download from Mega website

[TRICK] How to download from Mega website​**Especially for those who doesn't have Admin privileges**​
Hi All,
If you have admin privileges you can manually change DNS Server number and access Mega. But unfortunately many may not have Admin rights to modify Network Settings. This guide/trick will provide you necessary tips to download from otherwise unavailable Mega site.
Usually, If you click on download link which is hosted on Mega (Many countries block it!) your browser will greet you with the message "The webpage unavailable" (See first image).
Let's solve this without editing network settings (DNS/VPN etc.).
Requirements:-
1. You need Chrome webbrowser for this. Install Chrome from here.
2. Now Open Chrome--> Goto Chrome Store--> Search for Unlimied Free VPN - Hola & Install this extention app. (Link Here)
Now the trick begins:-
1. Open Chrome and click on the download link. Still you will get the Page not available message. Now You will see some thing like this https://mega.co.nz/#!zBBESCxY!ulXdnKB9_2bvPyRr3aH7WNOP6orm_zkLgJow_1fKK8s in your address bar. (1st Image)
2. Select & Cut from back slash [ / ] after mega.co.nz to the end (like this example:- /#!zBBESCxY!ulXdnKB9_2bvPyRr3aH7WNOP6orm_zkLgJow_1fKK8s)
( Tip:- Use Ctrl+X). (2nd Image)
3. The address bar should have only this https://mega.co.nz (3rd Image)
4. Now Click on Hola extention and Select US or New Zealand or UK server.
(Note:- You may have to try selecting / changing servers few times, be patient, don't give up as it really works) See the Magic,
The mega site opens up.
5. Now paste the actual file address (which you cut in step no. 4) at the end of opened mega web page address and Press Enter. (4th Image)
6. Your download will be ready, now download the file. (See last/5th image)
Happy downloading.
Screen Shots:-
Or you could use Google DNS/VPN to bypass blocked sites
rishabh56 said:
Or you could use Google DNS/VPN to bypass blocked sites
Click to expand...
Click to collapse
We cannot change DNS manually if we are General user without admin rights.
Thanks brother it worked fine
use this tool for mega.com download
use this tool for downloading from mega.com
run it with admin rights, and then open the website
it works
Android plzz...
How to open mega in android
You have to use Mega App... Install it from Play Store.
Never use Hola. They don't have their own servers ! They exchange our internet for others ! Eg. If you are using a USA VPN, then your IP will used by someone else at the same time !

Categories

Resources