Downloading an .apk update

by dashman » Thu, 10 Feb 2011 23:40:03 GMT


Sponsored Links
 i'd like to allow users to download any updates directly
from my app (hosted on own server).

right now i do this:

the url contains a link to the http: link to the .apk file:

                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));

                startActivity(i);

minor problem is that the webviewer pops up briefly
and then the downloading starts.

visually not very nice.

is there a better way of doing this - w/o the webviewer
popping up.

-- 



Re: Downloading an .apk update

by Marcin Orlowski » Fri, 11 Feb 2011 00:00:00 GMT


 > is there a better way of doing this - w/o the webviewer

You can download APK (i.e. to SD card) yourself w/o need of WebView
and the just init install of downloaded package

-- 


Sponsored Links


Re: Downloading an .apk update

by Mark Murphy » Fri, 11 Feb 2011 00:23:16 GMT


 Don't forget to include the MIME type in the Intent, though.

On Thu, Feb 10, 2011 at 10:59 AM, Marcin Orlowski





-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to Android Development_ Version 3.4 Available!

-- 



Re: Downloading an .apk update

by dashman » Fri, 11 Feb 2011 01:11:08 GMT


 i set the mime-type like this

i.setType("application/vnd.android.package-archive");

and the app crashes.

if i comment out the line - no crash and the webview
opens and the .apk file is downloaded.

again the url points to a .apk file.

-- 



Re: Re: Downloading an .apk update

by Mark Murphy » Fri, 11 Feb 2011 01:44:32 GMT


 


Use setDataAndType(). setType() nulls out your Uri. And, again, this
is only needed if you follow Marcin's recommendation and download the
APK yourself, then use an Intent to kick off installation.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to Android Development_ Version 3.4 Available!

-- 



Re: Downloading an .apk update

by dashman » Fri, 11 Feb 2011 05:11:10 GMT


 ok - i see what marcin was suggesting.

i download the .apk to the sd card.

now - what intent do i start to install the .apk file.








-- 



Re: Re: Downloading an .apk update

by Kostya Vasilyev » Fri, 11 Feb 2011 05:20:29 GMT


 Something like this should work:

Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file),"application/vnd.android.package-archive"); 


startActivity(intent);

-- Kostya

11.02.2011 0:11, dashman :
ok - i see what marcin was suggesting. i download the .apk to the sd card. now - what intent do i start to install the .apk file.
i set the mime-type like this i.setType("application/vnd.android.package-archive"); and the app crashes.
Use setDataAndType(). setType() nulls out your Uri. And, again, this is only needed if you follow Marcin's recommendation and download the APK yourself, then use an Intent to kick off installation. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguyhttp ://commonsware.com/blog| http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.4 Available!
-- Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com --



Re: Re: Downloading an .apk update

by Mark Murphy » Fri, 11 Feb 2011 05:28:39 GMT


 ACTION_VIEW, IIRC. Just specify a path to the downloaded file for the
Uri to setDataAndType().









-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

Android App Developer Books:  http://commonsware.com/books 

-- 



Re: Downloading an .apk update

by Traveler » Fri, 11 Feb 2011 22:49:36 GMT


 The following url explains how to install an .apk file from your SD
card. My daughter helps me test my projects, so she installs the .apk
to her Droid after I send it to her as an e-mail attachment.

 http://www.ieumart.com/how-to-install-apk-files-through-desktop-using-windows-vista.html 








-- 



Re: Re: Downloading an .apk update

by Marcin Orlowski » Fri, 11 Feb 2011 23:08:34 GMT


 


The link you gave is irrelevant to the former subject. We talk
here about installing APK from own code, w/o need of any
external tools like adb nor desktop box.

-- 



Other Threads

1. thousands of strings

Hello,

Maybe some of you has an application with quotations or jokes or
something. I would like to make a similar.
So how can I get the i. element of my string array (which is in
arrays.xml)? I don't want to load the whole array in a String[],
because it can be too big.
Or it's not a good idea to put them into arrays.xml? How do you handle
thousands of strings?

Evi

-- 

2. WebView - Unable to call a dynamically added Javascript (part of a HTML) inside a DIV using innerHTML

Hi Android experts,

I have a weird code situation where I need to have a <DIV> to hold
dynamic HTML generated. Here I am populating the <DIV> using its
innerHTML attribute and it works fine and dynamically adds any HTML
elements that are there in the dynamic HTML.

The problem I am facing now is if the dynamic (generated else where)
HTML contains a list of Javascript methods, these methods aren't
accessible to be callable from the buttons inside the div or outside
the div (

I was able to get the requirement working in Desktop Internet Explorer
7+. This however doesn't work on Firefox too . I understand this isn't
the best way, but to use addChild etc is, but then I would have to
manually parse my HTML myself and construct all the child elements i.e
do all that the innerHTML will do eventually (logically, i mean).

////////////////////////////////////////////Code also uploaded to
http://pastebin.com/Q6w5hRPG ////////////////////////////
////////////////////////////////////////////Code works on Internet
Explorer 7+//////////////////////////////////////////////////////
<html>
        <head>
                <script>
                        /* the input type = hidden is necessary or the JS won't 
be
accessible */
                        /* script defer tag is also necessary */
                        function insertHTMLOnButtonPress() {
                                var s = "<html><input type='hidden' 
id='dummyHidden'/
{ alert('Successfully called - dynamicallyInsertedFunction'); } </sc"
+ "ript></head><body><input type='text' value='Hello World'/><input
type='button' onClick='dynamicallyInsertedFunction();' value='Call
Dynamically Inserted Method'/></body></html>";
                                /* Clearing out innerHTML is also required to 
flush the innerHTML
so that repeated attempts - i.e new HTML/JS should work */
                                document.getElementById('tempBody').innerHTML = 
'';
                                document.getElementById('tempBody').innerHTML = 
s;
                        }
                </script>
        </head>
        <body>
                **********************************<br/>
                <!-- Don't close the div inline, causes some problem and 
replaces
the buttons too -->
                <div id="tempBody"></div>
                **********************************<br/>
                <input type="button" onClick="insertHTMLOnButtonPress();"
value="Insert some dynamic html"/>
                <input type="button" onClick="dynamicallyInsertedFunction();"
value="Call Dynamically Inserted Method"/>
        </body>
</html>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Also posted on WebDeveloper.com - 
http://www.webdeveloper.com/forum/showpost.php?p=1116504

-- 

3. App2sd

4. Samsung Galaxy Camera flash-mode and zoom-supported oddities

5. ImageView slow when using SetImageResource and MediaPlayer

6. even i have an color state issue with list view selection & swipe

7. Design/"flowchart" scheme for Android apps?