Class: Android::Manifest::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/android/manifest.rb

Overview

<activity>, <service>, <receiver> or <provider> element in <application> element of the manifest file.

Direct Known Subclasses

Activity, Application, Provider, Receiver, Service

Constant Summary collapse

TYPES =

component types

['activity', 'activity-alias', 'service', 'receiver', 'provider', 'application', 'queries']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elem) ⇒ Component

Returns a new instance of Component.

Parameters:

  • elem (REXML::Element)

    target element

Raises:

  • (ArgumentError)

    when elem is invalid.



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/android/manifest.rb', line 39

def initialize(elem)
  raise ArgumentError unless Component.valid?(elem)

  @elem = elem
  @type = elem.name
  @name = elem.attributes['name']
  @icon_id = elem.attributes['icon']

  @intent_filters = parse_intent_filters
  @metas = parse_metas
end

Instance Attribute Details

#elemREXML::Element (readonly)

Returns:

  • (REXML::Element)


35
36
37
# File 'lib/android/manifest.rb', line 35

def elem
  @elem
end

#icon_idString (readonly)

Returns icon id - use apk.icon_by_id(icon_id) to retrieve it’s corresponding data.

Returns:

  • (String)

    icon id - use apk.icon_by_id(icon_id) to retrieve it’s corresponding data.



29
30
31
# File 'lib/android/manifest.rb', line 29

def icon_id
  @icon_id
end

#intent_filtersArray<Manifest::IntentFilters<Manifest::IntentFilter>> (readonly)

Returns:



31
32
33
# File 'lib/android/manifest.rb', line 31

def intent_filters
  @intent_filters
end

#metasArray<Manifest::Meta> (readonly)

Returns:



33
34
35
# File 'lib/android/manifest.rb', line 33

def metas
  @metas
end

#nameString (readonly)

Returns component name.

Returns:

  • (String)

    component name



27
28
29
# File 'lib/android/manifest.rb', line 27

def name
  @name
end

#typeString (readonly)

Returns type string in TYPES.

Returns:

  • (String)

    type string in TYPES



25
26
27
# File 'lib/android/manifest.rb', line 25

def type
  @type
end

Class Method Details

.valid?(elem) ⇒ Boolean

the element is valid Component element or not

Parameters:

  • elem (REXML::Element)

    xml element

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/android/manifest.rb', line 18

def self.valid?(elem)
  TYPES.include?(elem.name.downcase)
rescue
  false
end