Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declare Inner Activity In The Android Manifest

In my thread I create an inner activity 'B' at one point in order to launch another activity for result. I need to declare this in my Android manifest file but can not work out what the name of it is as the standard ".B" does not work as it says that activity does not exist. How can I declare this activity?

Thanks

like image 249
Darius Avatar asked Sep 10 '10 19:09

Darius


People also ask

How do I declare an activity in manifest XML?

There are several other attributes that you can include in this element, to define properties such as the label for the activity, an icon for the activity, or a theme to style the activity's UI. The android:name attribute is the only required attribute—it specifies the class name of the activity.

Why do we have to declare activities in manifest file?

Because it lets you define the structure and metadata of your android application and its components.


2 Answers

  1. As someone pointed out, in AndroidManifest, use the $ sign, like:

    <activity android:name=".A$B">
    
  2. Declare class B as static:

    public static class B
    
like image 123
wwyt Avatar answered Nov 05 '22 05:11

wwyt


To reference an inner class use the "$" instead of a dot.

.A$B

It may also be prefaced with the package path

com.yourcompany.projectname.A$B
like image 27
Kaili Avatar answered Nov 05 '22 05:11

Kaili