What the hell is application/vnd.android.package-archive?

Source: Internet
Author: User

In the reading group, PKU developed the Android code,

Read the code updated after detecting the version before logging in. Found a place that did not understand.

void Update () {Intent Intent = new Intent (Intent.action_view); Intent.setdataandtype (Uri.fromfile (New File Environment.getexternalstoragedirectory (), m_appnamestr)), "application/vnd.android.package-archive"); LOG.E ("msg", environment.getexternalstoragedirectory () + "" "+ M_appnamestr); startactivity (intent);}
Where M_appnamestr is the name of the app that was downloaded to the local.

In Intent.setdataandtype, the front is the location of the APK that reads the SD memory card,

Application/vnd.android.package-archive
What does it mean.

Search directly for this and find that this section appears in your code, but it doesn't explain what this is all about.

First wiki:http://zh.wikipedia.org/wiki/apk

ANDROID  application package file   ( APK ) is an application installation file format on an Android operating system, Its English is all called   application package file  . The code of an Android application wants to run on an Android device, it must be compiled, then packaged into a file that is recognized by the Android system to be run, and the file format that can be recognized and run by the Android system is "APK". An APK file contains a compiled code file (. dex file), a file resource (resources), a assets, a certificate (certificates), and a manifest (manifest file). [1][2][3][4]

The APK file is based on the ZIP file format, similar to how the jar file is constructed. The type of Internet media it is application/vnd.android.package-archive . [5]

See. Application/vnd.android.package-archive is the Internet media type for APK.
What is the type of Internet media? Never heard of it before.
Once again look at Wiki:<a target=_blank href= "http://zh.wikipedia.org/wiki/%E4%BA%92%E8%81%94%E7%BD%91%E5%AA%92%E4%BD%93% e7%b1%bb%e5%9e%8b ">http://zh.wikipedia.org/wiki/%e4%ba%92%e8%81%94%e7%bd%91%e5%aa%92%e4%bd%93%e7%b1%bb%e5% 9e%8b</a>
internet media type(Internet media type), originally called "Type MIME"or"Mime"or the type of content after the various protocols in the header information (Content-type), he had two parts used inInterneton the identificationData format. The identification method has beenRfcdefined in 2046, used in e-mail throughSmtp. But he has been extended to other protocols, such as:HTTPorSip. A type MIME consists of at least two parts: a type and a subtype and one or more other required parameters. For example, a sub-typetextAn optional parameter charset is used to indicateCharacter encoding; or amultipartA subtype of type defines an optionBoundary. Those types and subtypes that start with "X" are not standard and they cannot be stored if the applicationIana. Those subtypes that start with "VND" are merchant information.

VND = Vendor StackOverflow The great God is explained below.

Types or subtypes that begin with X-are nonstandard (they is not registered with IANA). Subtypes that begin withvndIs vendor-specific. Subtypes in the personal or vanity tree begin withprs.


<span style= "FONT-SIZE:18PX;" > finally looking at Intent.setdataandtype (uri.fromfile (Environment<span style= "White-space:pre" ></span >.getexternalstoragedirectory (), m_appnamestr), <span style= "White-space:pre" ></span> "Application /vnd.android.package-archive "); </span>
this piece of code

Intent Android.content.Intent.setDataAndType (Uri data,String type)
Parameters:
Data the Uri of the data this intent are now
targeting.
Type the MIME type of the data being handled by this intent.
Return:
Returns the same Intent object, for chaining multiple calls to a single statement.
The parameter requires a URI and an Internet media type that returns a intent object.

With Setdataandtype you can update, download, open new apps and more.


Install APK

String Dirpath = "/data/data/" + getpackagename () + "/files/test.apk"; The file needs to have the readable permission  Intent Intent = new Intent ();  Intent.setaction (Android.content.Intent.ACTION_VIEW);  Intent.setdataandtype (Uri.parse ("file://" + FilePath), "application/vnd.android.package-archive");  Intent.setflags (Intent.flag_activity_new_task);  


Finally, it's a disgusting thing to see the code. In particular, there is no commented code.

But on the way to see, almost all of the code is on the Internet as a whole pulled down, can not understand the place directly Google a bit. will be able to find the original version.

also drunk. Copy someone else's even. For Mao to delete the note. Peking University, Peking University ~ ~


What the hell is application/vnd.android.package-archive?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.