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. Keyboard Character Replacement

Hi,

How to replace a keyboard character?..

Ex:-  'Enter' Button should be changed to 'Search' or 'Done'

http://betterandroid.files.wordpress.com/2009/05/61.png


<http://betterandroid.files.wordpress.com/2009/05/61.png>
http://betterandroid.files.wordpress.com/2009/05/51.png

-- 
Thanks & Regards
Sasikumar.S

-- 

2. Strange NullPointerException in WebView.onTouchEvent in Android 2.1 Update 1

For some reason, since upgrading to Android 2.1 Update 1 (stock Nexus
One), I occasionally get NullPointerException in WebView.onTouchEvent
method. It does not happen all the time and that makes it difficult to
track down.  Here is the stack trace:

java.lang.NullPointerException
        at android.webkit.WebView.onTouchEvent(WebView.java:3977)
        at android.view.View.dispatchTouchEvent(View.java:3709)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:852)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
        at com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
        at
com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:
1107)
        at android.app.Dialog.dispatchTouchEvent(Dialog.java:643)
        at com.android.internal.policy.impl.PhoneWindow
$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
        at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:123)
        at android.app.ActivityThread.main(ActivityThread.java:4363)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:521)
        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:860)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
        at dalvik.system.NativeStart.main(Native Method)


It appears to happen after the device resumes from sleep. I also tried
looking at the latest repo source, but the line number (3977) while it
is in the correct function is on line that does not make much sense to
cause the exception.

Has anyonhe seen a similar issue or knows where to get the correct
source of WebView.java that matches the released 2.1 Update 1?

Stefan

-- 

3. Eclipse Emulator

4. ALSA mixers

5. Search @ Market

6. Launcher activity

7. i want to control speed "ellipsize=marquee"