Skip to content

Commit c5364ba

Browse files
committed
add more examples
1 parent 849c19d commit c5364ba

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

README.md

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,67 @@ androidbinary
66

77
Android binary file parser
88

9-
## Parse XML binary
9+
## High Level API
10+
11+
### Parse APK files
1012

1113
``` go
1214
package main
1315

1416
import (
15-
"fmt"
17+
"github.com/shogo82148/androidbinary/apk"
18+
)
19+
20+
func main() {
21+
pkg, _ := apk.OpenFile("your-android-app.apk")
22+
defer pkg.Close()
23+
24+
icon, _ := apk.Icon(nil) // returns the icon of APK as image.Image
25+
pkgName := pkg.PackageName() // returns the pakcage name
26+
}
27+
```
28+
29+
## Low Lebel API
30+
31+
### Parse XML binary
32+
33+
``` go
34+
package main
35+
36+
import (
37+
"encoding/xml"
38+
1639
"github.com/shogo82148/androidbinary"
17-
"os"
40+
"github.com/shogo82148/androidbinary/apk"
1841
)
1942

2043
func main() {
21-
f, _ := os.Open("AndroidManifest")
44+
f, _ := os.Open("AndroidManifest.xml")
2245
xml, _ := androidbinary.NewXMLFile(f)
2346
reader := xml.Reader()
47+
2448
// read XML from reader
49+
var manifest apk.Manifest
50+
data, _ := ioutil.ReadAll(reader)
51+
xml.Unmarshal(data, &manifest)
52+
}
53+
```
54+
55+
### Parse Resource files
56+
57+
``` go
58+
package main
59+
60+
import (
61+
"fmt"
62+
"github.com/shogo82148/androidbinary"
63+
)
64+
65+
func main() {
66+
f, _ := os.Open("resources.arsc")
67+
rsc, _ := androidbinary.NewTableFile(f)
68+
resorce, _ := rsc.GetResource(androidbinary.ResId(0xCAFEBABE), nil)
69+
fmt.Println(resource)
2570
}
2671
```
2772

0 commit comments

Comments
 (0)