| Interface | Description |
|---|---|
| Result |
Object passed to intent handler which should be notified about computed
result.
|
| Annotation Type | Description |
|---|---|
| IntentHandlerRegistration |
Annotation for registering Intent handlers into the application.
|
Handling some type of Intents is as simple as registering a method using
annotation IntentHandlerRegistration.
Currently two types of handling methods are supported:
Intent and
returning Object. This method will be invoked in a
background thread. It is suitable if no waiting for asynchronous operations
is needed and when the method will finish reasonably quickly (so that it
will not block execution of other intents).
Intent and
Result with no return type (void). It will be
invoked in a background thread, but it can simply pass the result object to
other threads. When the computation is finished, either
Result.setException(java.lang.Exception) or
Result.setResult(java.lang.Object)
MUST be called on the result object.
See examples:
Basic handler:
@IntentHandlerRegistration( displayName = "Show my item in MyEditor", position = 800, uriPattern = "myscheme://.*", actions = {Intent.ACTION_VIEW, Intent.ACTION_EDIT} ) public static Object handleIntent(Intentintent) { SomeType result = parseAndPerformIntentSomehow(intent); return result; }
Handler that uses Result:
@IntentHandlerRegistration( displayName = "Show my item in MyEditor", position = 800, uriPattern = "myscheme://.*", actions = "*" ) public static void handleIntent(finalIntentintent, finalResultresult) { EventQueue.invokeLater(new Runnable() { public void run() { try { Object value = doSomethingInEDT(intent); result.setResult(value); } catch (Exception e) { result.setException(e); } } }); }