TwitcH
TwitcH

Reputation: 21

WebView displays .pkg file instead of downloading it

Hi all I need some help here I have gone through the tutorial for WebView and I get it to load my url and it loads fine. I run a site that offers .pkg files to my users for download to there device. The issue is instead of downloading the .pkg file it just displays the raw code of the .pkg file in the webview. How can I get this to force download to the root of the sd card? Here is what I have

package com.ps3brew.view;

import com.ps3brew.view.R;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class WebViewExample extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        WebView webView = (WebView) findViewById(R.id.webview);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("http://www.myurl.com/phone.html");

        webView.setWebViewClient(new HelloWebViewClient());

    }
}

Any help would be great I am 100% new to this android dev and im just stuck everything I have tried has failed any help would be great. Thanks in advance

Upvotes: 1

Views: 2127

Answers (2)

cistearns
cistearns

Reputation: 2508

I would verify that your html page works in the normal android browser first. My guess is that the MIME type for apk's on your server are incorrect.

The MIME type should be application/vnd.android.package-archive

In addition users will need to set the phone system preferences to allow installation of non-Market applications.

Upvotes: 1

BlackDragonBE
BlackDragonBE

Reputation: 302

What happens if you long-click the link? Can you download it that way?
You might want to consider scraping the links and designing a GUI with a list instead of simply sending the user to the full website.

Upvotes: 0

Related Questions