mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-02-04 18:36:01 +02:00
Misc. Android Improvements (#2325)
- Add missing package declaration on the AIDL interface slide. - Make the parcelable example more self-contained. The existing code was referencing variables that weren't declared in the example code. - Add a speaker note to the logging slide about explaining that the logger implementation is only needed in binaries, and that just the log facade is needed in libraries.
This commit is contained in:
parent
9c16b36b5e
commit
d2bc223a06
@ -12,7 +12,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// ANCHOR: package
|
||||
package com.example.birthdayservice;
|
||||
// ANCHOR_END: package
|
||||
|
||||
import com.example.birthdayservice.IBirthdayInfoProvider;
|
||||
import com.example.birthdayservice.BirthdayInfo;
|
||||
|
@ -43,9 +43,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
println!("{msg}");
|
||||
// ANCHOR_END: main
|
||||
|
||||
// ANCHOR: wish_with_info
|
||||
service.wishWithInfo(&BirthdayInfo { name: name.clone(), years })?;
|
||||
// ANCHOR_END: wish_with_info
|
||||
|
||||
// ANCHOR: wish_with_provider
|
||||
|
||||
|
@ -5,6 +5,8 @@ You declare the API of your service using an AIDL interface:
|
||||
_birthday_service/aidl/com/example/birthdayservice/IBirthdayService.aidl_:
|
||||
|
||||
```java
|
||||
{{#include ../birthday_service/aidl/com/example/birthdayservice/IBirthdayService.aidl:package}}
|
||||
|
||||
{{#include ../birthday_service/aidl/com/example/birthdayservice/IBirthdayService.aidl:IBirthdayService}}
|
||||
}
|
||||
```
|
||||
|
@ -25,6 +25,7 @@ fn main() {
|
||||
binder::ProcessState::start_thread_pool();
|
||||
let service = connect().expect("Failed to connect to BirthdayService");
|
||||
|
||||
{{#include ../birthday_service/src/client.rs:wish_with_info}}
|
||||
let info = BirthdayInfo { name: "Alice".into(), years: 123 };
|
||||
service.wishWithInfo(&info)?;
|
||||
}
|
||||
```
|
||||
|
@ -32,3 +32,10 @@ adb logcat -s rust
|
||||
09-08 08:38:32.454 2420 2420 I rust: hello_rust_logs: Things are going fine.
|
||||
09-08 08:38:32.454 2420 2420 E rust: hello_rust_logs: Something went wrong!
|
||||
```
|
||||
|
||||
<details>
|
||||
|
||||
- The logger implementation in `liblogger` is only needed in the final binary,
|
||||
if you're logging from a library you only need the `log` facade crate.
|
||||
|
||||
</details>
|
||||
|
Loading…
x
Reference in New Issue
Block a user