You Daniel, I MsgReceiver class (a class that inherits from BroadcastReceiver) as an internal class and placed in an Activity for updates on the Activity display when receiving broadcasts. In AndroidManifest.xml, if something like this can be placed inside the , eclipse would be an error, the error is: The element must be a direct child of the < application> element. But after Problems in the wrong delete out, it works: android: label = "@ string / app_name" android: screenOrientation = "portrait">
If like this on the outside , although the eclipse does not complain, but the runtime will crash, reported instances can not be created MsgReceiver exception: android: label = "@ string / app_name" android: screenOrientation = "portrait">
I use downloaded from the official website ADT bundle development, SDK 4.3, the test machine is a 2.3 system. Will be placed AndroidManifest in inside it? If not, between the Receiver and the need to update the Activity should be what is the relationship? How to communicate? Thank you!
<-! Baidu Button BEGIN -> more Share to: <-! Baidu Button END ->
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) -> Reply:
In fact, you can register the broadcast through the code inside the Activity Reply: To be on the outside, so write MsgReceiver got to be defined as static, no current context activity of. May also need an empty constructor, do not remember, huh
Reply:
I ask specifically how to register? Give an example? Thank you! Reply:
Many online http://www.cnblogs.com/qianlifeng/archive/2011 / 03/06/1972305.html Reply: Registered way Android receiver includes dynamic and static registration registration. Dynamic registration refers to create an instance of a subclass BroadcastReceiver receiver need to be registered in the class, and then use registerReceiver () function is registered receiver and action appropriate filters. The receiver dynamic registration is only valid in the program is running. Static registration required AndroidManifest registration, registered a manner similar to what you write second AndroidManifest, but this approach requires inherited BroadcastReceiver in a separate class, the inner class is of no use. Static registered Whether you are starting a program are valid.
You can see if you are using a kind of registration, if you are using a dynamic registration, simply put AndroidManifest in part can be deleted; If it is a static registration, can not be used inside the class.
Reply:
Registered way
Android receiver includes dynamic and static registration registration. Dynamic registration refers to create an instance of a subclass BroadcastReceiver receiver need to be registered in the class, and then use registerReceiver () function is registered receiver and action appropriate filters. The receiver dynamic registration is only valid in the program is running. Static registration required AndroidManifest registration, registered a manner similar to what you write second AndroidManifest, but this approach requires inherited BroadcastReceiver in a separate class, the inner class is of no use. Static registered Whether you are starting a program are valid.
You can see if you are using a kind of registration, if you are using a dynamic registration, simply put AndroidManifest in part can be deleted; If it is a static registration, can not be used inside the class.
Registration is possible to use a static inner classes, inner classes can only use static methods or members of the outer class, no external class context. Reply:
Registered way Android receiver includes dynamic and static registration registration. Dynamic registration refers to create an instance of a subclass BroadcastReceiver receiver need to be registered in the class, and then use registerReceiver () function is registered receiver and action appropriate filters. The receiver dynamic registration is only valid in the program is running. Static registration required AndroidManifest registration, registered a manner similar to what you write second AndroidManifest, but this approach requires inherited BroadcastReceiver in a separate class, the inner class is of no use. Static registered Whether you are starting a program are valid.
You can see if you are using a kind of registration, if you are using a dynamic registration, simply put AndroidManifest in part can be deleted; If it is a static registration, can not be used inside the class.
Registration is possible to use a static inner classes, inner classes can only use static methods or members of the outer class, no external class context.
You mean the use of static inner classes modified it? If not, then the concrete is how to achieve it? Reply: Not allow a class to inherit both inherited Activity and broadcast it? Reply:
Registered way Android receiver includes dynamic and static registration registration. Dynamic registration refers to create an instance of a subclass BroadcastReceiver receiver need to be registered in the class, and then use registerReceiver () function is registered receiver and action appropriate filters. The receiver dynamic registration is only valid in the program is running. Static registration required AndroidManifest registration, registered a manner similar to what you write second AndroidManifest, but this approach requires inherited BroadcastReceiver in a separate class, the inner class is of no use. Static registered Whether you are starting a program are valid.
You can see if you are using a kind of registration, if you are using a dynamic registration, simply put AndroidManifest in part can be deleted; If it is a static registration, can not be used inside the class.
Registration is possible to use a static inner classes, inner classes can only use static methods or members of the outer class, no external class context.
You mean the use of static inner classes modified it? If not, then the concrete is how to achieve it?
Is modified with static. Reply:
not allow a class to inherit both inherited Activity and broadcast it?
No comments:
Post a Comment