forked from androidannotations/androidannotations
-
Notifications
You must be signed in to change notification settings - Fork 0
Extras
PerfectCarl edited this page May 28, 2014
·
10 revisions
Since AndroidAnnotations 1.0
The @Extra
annotation indicates that an activity field should be injected with the corresponding Extra from the Intent that was used to start the activity.
Usage example:
@EActivity
public class MyActivity extends Activity {
@Extra("myStringExtra")
String myMessage;
@Extra("myDateExtra")
Date myDateExtraWithDefaultValue = new Date();
}
Since AndroidAnnotations 2.6
If you do not provide any value for the @Extra
annotation, the name of the field will be used.
@EActivity
public class MyActivity extends Activity {
// The name of the extra will be "myMessage"
@Extra
String myMessage;
}
Note that you can use the intent builder to pass extra values.
MyActivity_.intent().myMessage("hello").start() ;
Since AndroidAnnotations 2.6
AndroidAnnotations overrides setIntent()
, and automatically reinjects the extras based on the given Intent
when you call setIntent()
.
This allows you to automatically reinject the extras by calling setIntent()
from onNewIntent()
.
@EActivity
public class MyActivity extends Activity {
@Extra("myStringExtra")
String myMessage;
@Override
protected void onNewIntent(Intent intent) {
setIntent(intent);
}
}
AndroidAnnotations was created by Pierre-Yves Ricau and is sponsored by eBusinessInformations.
27/12/2013 The 3.0 release is out !
- Get started!
- Download
- Cookbook, full of recipes
- Customize annotation processing
- List of all available annotations
- Release Notes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue
- Tag on Stack Overflow