Webview and .apk files

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Webview and .apk files

Postby SamuraiZack » Wed Jul 07, 2010 11:30 pm

Can someone explain me how I would be able to imitate the default browser when trying to download .apk from the net?

So far I have this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         WebView webview;
  2.        
  3.         @Override
  4.         public void onCreate(Bundle icicle)
  5.                 {
  6.                 super.onCreate(icicle);
  7.                 setContentView(R.layout.main);
  8.                
  9.                 webview = (WebView) findViewById(R.id.webview);
  10.                 webview.setWebViewClient(new HelloWebViewClient());
  11.                 WebSettings webSettings = webview.getSettings();
  12.                 webSettings.setSavePassword(false);
  13.                 webSettings.setSaveFormData(false);
  14.                 webSettings.setJavaScriptEnabled(true);
  15.                 webSettings.setSupportZoom(false);
  16.                
  17.                 webview.setDownloadListener(new DownloadListener() {
  18.                         public void onDownloadStart(final String url, String userAgent,
  19.                         String contentDisposition, String mimetype,
  20.                         long contentLength) {
  21.                         Toast.makeText(testapp.this, url, Toast.LENGTH_LONG);
  22.                         }
  23.                         });
  24.  
  25.                 webview.loadUrl("http://dacp.jsharkey.org/TunesRemote-r2.apk");      
  26.                
  27.                 }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


I've already added the permission to use the internet. Are there any other permissions that I need to add? Am I doing the DownloadListener incorrectly?

Thank you in advance!
SamuraiZack
Freshman
Freshman
 
Posts: 2
Joined: Tue Jul 06, 2010 10:29 pm

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests