07-29-2010 09:48 AM - edited 07-29-2010 09:50 AM
My app registers itselfs as a ContentHandler similar to the SendMediaDemo sample app does:
/**
* Registers this application as a content handler for image files
*/
private void register() {
_log.info("Registering itself as a content handler");
// Get access to the registry
Registry registry = Registry.getRegistry(CLASSNAME);
// only register if we did not register before
ContentHandler handler = registry.forID(ID, true);
if(handler != null) {
_log.info("We are already registered");
return;
}
String[] types = { "image/bmp", "image/png", "image/jpeg",
"video/3gpp", "video/mp4" };
String[] suffixes = { ".bmp", ".png", ".jpg", ".3GP", ".mp4" };
String[] actions = { ContentHandler.ACTION_SEND };
String[] actionNamesEn = { "Send to Hyves" };
String[] actionNamesNl = { "Verstuur naar Hyves" };
ActionNameMap[] actionNameMaps = {
new ActionNameMap(actions, actionNamesEn, "en"),
new ActionNameMap(actions, actionNamesNl, "nl") };
try {
// Register as a content handler
registry.register(CLASSNAME, types, suffixes, actions,
actionNameMaps, ID, null);
} catch (ContentHandlerException e) {
e.printStackTrace();
_log.error("Registering as content handler failed: "
+ e.toString());
} catch (SecurityException e) {
e.printStackTrace();
_log.error("Registering as content handler failed: "
+ e.toString());
} catch (IllegalArgumentException e) {
e.printStackTrace();
_log.error("Registering as content handler failed: "
+ e.toString());
} catch (ClassNotFoundException e) {
e.printStackTrace();
_log.error("Registering as content handler failed: "
+ e.toString());
}
}
It of course also hasa method that handles the invocation :
public void invocationRequestNotify(ContentHandlerServer server) {
Invocation invoc = server.getRequest(false);
if (invoc != null) {
String type = invoc.getType();
String url = invoc.getURL();
byte[] data = invoc.getData();
_log.info("invocationRequestNotify " + invoc + " type: " + type
+ " url: " + url + " data.length: " + data.length);
if (type.equals("image/bmp") || type.equals("image/png")
|| type.equals("image/jpeg")) {
if (url.equals("file://nullnullnull")) {
url = null;
// Not Supported due to Blackberry BUG
// https://www.blackberry.com/jira/browse/JAVAAPI-963");
// workaround this issue by querying the file journal and
// getting the last file that has changed
long nextUSN = FileSystemJournal.getNextUSN();
for (long lookUSN = nextUSN - 1; lookUSN >= 0; lookUSN--) {
FileSystemJournalEntry entry = FileSystemJournal
.getEntry(lookUSN);
if (entry == null) {
// we didn't find an entry.
break;
}
if (entry.getEvent() == FileSystemJournalEntry.FILE_ADDED) {
url = "file://" + entry.getPath();
break;
}
}
}
if(url!=null) {
enqueueUploadRequest(url);
}
} else if (type.equals("video/3gpp") || type.equals("video/mp4")) {
// we dont handle videos yet
} else {
_log.info("invocationRequestNotify unkown type " + type);
}
server.finish(invoc, Invocation.OK);
}
}
Now if i open de camera app, make a picture , click share.. select my app "Share with my app"
it works fine.. Then if a press back (going from my app to the camera app again). And then press share again.. and share via my app... i get this exception, and my app is never called:
Thread [net_rim_bb_camera(195)id=342797312] (Suspended (exception IllegalStateException)) RegistryImpl.invoke(Invocation, Invocation) line: 711 RegistryImpl.invoke(Invocation) line: 680 ContentHandlerVerbFactory$ContentHandlerVerb.invoke(Object) line: 121 CameraPreviewScreen.openSendDialog() line: 557 CameraPreviewScreen$3.run() line: 761 SystemEnabledMenu(Menu).show(DefaultMenuScreen) line: 1309 SystemEnabledMenu(Menu).show() line: 1196 SystemEnabledMenu.show() line: 411 CameraPreviewScreen(Screen).onMenu(int) line: 3911 CameraPreviewScreen(Screen).keyCharUnhandled(char, int, int) line: 3029 CameraPreviewScreen(MainScreen).keyCharUnhandled(c har, int, int) line: 320 CameraPreviewScreen(Screen).dispatchKeyEvent(IKeyE vent) line: 697 CameraPreviewScreen(Screen).processKeyEvent(IKeyEv ent) line: 3440 UiEngineImpl.processMessage(Object, Message, boolean) line: 3635 CameraMain(Application).doProcessNextMessage(Messa ge) line: 2268 CameraMain(Application).processNextMessage(Message ) line: 1530 CameraMain(Application).enterEventDispatcher() line: 1371 CameraMain.main(String[]) line: 156
If i close and reopen the camera app everything is fine again.
What am i doing wrong here?
07-30-2010 02:17 PM
What BlackBerry Smartphone model and BlackBerry device software version are you testing on? You can find this under Options, About on the BlackBerry Smartphone.
08-17-2010 06:38 PM
Have the same problem on BlackBerry 9330 v5.0.0.782.
It only happens with the camera app. In Media browser I can click select my app in "send or share" multiple times and it works every time.
08-18-2010 02:41 PM
This is a known issue, which has been fixed in BlackBerry device software version 5.0.0.838 and higher. I don't have a work around to provide for existing releases.
08-19-2010 08:40 AM
So can you then explain:
- Why does it work flawlessly for twitter and facebook
- Why doesnt it work on the BlackBerry torch: i have the same problem there... however i could find the IllegalStateException in the console... however going back and then sharing again fails.
B.t.w i have a Beta blackberry Torch here, sent by BlackBerry.
Greetings
08-19-2010 11:13 AM
The Twitter and Facebook applications were created by RIM using internal APIs.
The exception is caused by a problem with the Camera application, which has been fixed.