get version from apk

7233 views
Skip to first unread message

engin

unread,
Aug 16, 2009, 6:30:18 AM8/16/09
to Android Developers
Hi, can I get version from .apk file. I tried to open
androidmanifest.xml but I realized that xml files are destructed when
apk created.

Greivin Lopez

unread,
Aug 17, 2009, 10:24:08 AM8/17/09
to Android Developers
Hi, you could use PackageInfo class to retrieve some information from
Manifest.xml.

Try to use this code:
/**
* Gets the software version retrieved from the Manifest.
*/
private String getSoftwareVersion() {
try {
PackageInfo packageInfo = getPackageManager
().getPackageInfo(getPackageName(), 0);
return packageInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Package name not found", e);
};

Dianne Hackborn

unread,
Aug 17, 2009, 1:49:21 PM8/17/09
to android-d...@googlegroups.com
If you want this from the desktop, use "aapt dump badging <path/to/apk>".
--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

engin

unread,
Aug 17, 2009, 2:47:32 PM8/17/09
to Android Developers
thanks hackborn it works.

On Aug 17, 8:49 pm, Dianne Hackborn <hack...@android.com> wrote:
> If you want this from the desktop, use "aapt dump badging <path/to/apk>".
>
> On Mon, Aug 17, 2009 at 7:24 AM, Greivin Lopez <greivin.lo...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Hi, you could use PackageInfo class to retrieve some information from
> > Manifest.xml.
>
> > Try to use this code:
> >    /**
> >     * Gets the software version retrieved from the Manifest.
> >     */
> >    private String getSoftwareVersion() {
> >        try {
> >                PackageInfo packageInfo = getPackageManager
> > ().getPackageInfo(getPackageName(), 0);
> >                return packageInfo.versionName;
> >        } catch (PackageManager.NameNotFoundException e) {
> >                Log.e(TAG, "Package name not found", e);
> >        };
> >     }
>
> > On Aug 16, 4:30 am, engin <enginarsla...@gmail.com> wrote:
> > > Hi, can I get version from .apk file. I tried to open
> > > androidmanifest.xml but I realized that xml files are destructed when
> > > apk created.
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages