org.androidannotations.annotations.OnActivityResult Maven / Gradle / Ivy
Show all versions of androidannotations-api Show documentation
/**
* Copyright (C) 2010-2016 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* This annotation is intended to be used on methods to receive results from a
* previously started activity using
* {@link android.app.Activity#startActivityForResult(android.content.Intent, int)
* Activity#startActivityForResult(Intent, int)} or the generated
* IntentBuilder.startActivityForResult()
method of the activity.
*
*
* The annotation value must be an integer constant that represents the
* requestCode associated with the given result.
*
*
* The method may have multiple parameter :
*
*
* - A {@link android.content.Intent Intent} that contains data
* - An
int
or an {@link java.lang.Integer Integer} to get the
* resultCode
* - Any native, {@link android.os.Parcelable Parcelable} or
* {@link java.io.Serializable Serializable} parameter annotated with
* {@link org.androidannotations.annotations.OnActivityResult.Extra
* OnActivityResult.Extra} to get an object put in the extras of the intent.
*
*
*
*
* Some usage examples of @OnActivityResult annotation:
*
*
* @OnActivityResult(REQUEST_CODE)
* void onResult(int resultCode, Intent data) {
* }
*
* @OnActivityResult(REQUEST_CODE)
* void onResult(int resultCode) {
* }
*
* @OnActivityResult(ANOTHER_REQUEST_CODE)
* void onResult(Intent data) {
* }
*
* @OnActivityResult(ANOTHER_REQUEST_CODE)
* void onResult(@OnActivityResult.Extra anExtra) {
* }
*
*
*
*
* @see EActivity
* @see android.app.Activity#startActivityForResult(android.content.Intent, int)
* @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface OnActivityResult {
/**
* The requestCode associated with the given result.
*
* @return the requestCode
*/
int value();
/**
*
* Use on any native, {@link android.os.Parcelable} or
* {@link java.io.Serializable} parameter of an {@link OnActivityResult}
* annotated method to bind it with the value from the Intent.
* If Parceler is on the classpath, extras
* annotated with @Parcel, or collections supported by Parceler will be
* automatically marshaled using a {@link android.os.Parcelable Parcelable}
* through the Parcels utility class.
*
*
* The annotation value is the key used for the result data. If not set, the
* field name will be used as the key.
*
*
*
*
* Some usage examples of @Result annotation:
*
*
* @OnActivityResult(REQUEST_CODE)
* void onResult(int resultCode, Intent data, @OnActivityResult.Extra String value) {
* }
*
* @OnActivityResult(REQUEST_CODE)
* void onResult(int resultCode, @OnActivityResult.Extra(value = "key") String value) {
* }
*
* @OnActivityResult(REQUEST_CODE)
* void onResult(@OnActivityResult.Extra String strVal, @OnActivityResult.Extra int intVal) {
* }
*
*
*
*
* @see android.app.Activity#onActivityResult(int, int,
* android.content.Intent)
* @see OnActivityResult
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.PARAMETER)
public @interface Extra {
/**
* They key of the result data.
*
* @return the key
*/
String value() default "";
}
}