Load URL from remote server

Tutorials with advanced 'difficulty' and more Lines of Code.

Load URL from remote server

Postby aptgopal » Tue Dec 07, 2010 5:26 pm

Hi all
I am new to android .In android is their any possibility to load html files in the web view from my remote server
Also i want to change the file in the particular period of time
Also i want to check the internet connection if it is available means load the web view otherwise i don't want to load the web view
Please any one help me

Thanks in Advance
aptgopal
Developer
Developer
 
Posts: 25
Joined: Tue Nov 16, 2010 7:08 pm
Location: India

Top

Re: Load URL from remote server

Postby adilkhash » Sat Jan 01, 2011 7:48 pm

look at java.net.* package

and don't be lazy to google.
User avatar
adilkhash
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Jan 01, 2011 10:37 am
Location: Kazakhstan

Re: Load URL from remote server

Postby d_a_l_3 » Sun Jul 03, 2011 4:13 pm

Here is function that I use and working
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private Drawable LoadImageFromWWW(String url)
  2.  {
  3.      try
  4.      {
  5.          InputStream is = (InputStream) new URL(url).getContent();
  6.          Drawable d = Drawable.createFromStream(is, "src name");
  7.          return d;
  8.      }
  9.      catch (Exception e)
  10.      {
  11.           return null;
  12.      }
  13.  }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Use like this

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Drawable drawable = LoadImageFromWWW("http://yoursite.com/destination_image.png");
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

and pass to image

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. img.setImageDrawable(drawable);
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


works for me :)
d_a_l_3
Freshman
Freshman
 
Posts: 2
Joined: Tue May 11, 2010 8:47 pm

Re: Load URL from remote server

Postby nuwud » Wed Oct 12, 2011 4:22 am

Will it work with video, too?
nuwud
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Aug 29, 2011 7:13 pm

Re: Load URL from remote server

Postby d_a_l_3 » Wed Oct 12, 2011 7:55 am

I think that for video will not work :(
d_a_l_3
Freshman
Freshman
 
Posts: 2
Joined: Tue May 11, 2010 8:47 pm

Top

Return to Advanced Tutorials

Who is online

Users browsing this forum: No registered users and 7 guests