BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 08-19-2009, 12:56 PM   #1
kosh
New Member
 
Join Date: Aug 2009
Model: n/a
PIN: N/A
Carrier: Rogers
Posts: 9
Default .cod files communicating with each other

Please Login to Remove!

Hi,

Im new to BB development. Just wondering if the below scenario is possible and how to set it up.

Is it possible, to have two '.cod' files under the same application such that, '1.cod' gets an image and url from '2.cod'. However, '1.cod' cannot be recompiled. The only thing I want to do is change the image and url in '2.cod' and recompile it so that '1.cod' picks up the latest image and url.

Please let me know how i could do this. Help is greatly appreciated.

Thanks

Last edited by kosh; 08-19-2009 at 12:58 PM..
Offline  
Old 08-19-2009, 01:55 PM   #2
hrbuckley
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Default

Yes you can. Off hand if you have either the source code or JAR file for 1.cod. Then you can have 2.cod call a method in 1.cod.

The other way would be to have 2.cod extend an object or implement an interface that 1.cod 'knows' about. 1.cod could fetch the class by name at run time, create an object and call a method.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 08-19-2009, 02:15 PM   #3
kosh
New Member
 
Join Date: Aug 2009
Model: n/a
PIN: N/A
Carrier: Rogers
Posts: 9
Default

thanks for the response.

I dont have the src or jar file for 1.cod....all I will have is the .cod file.

With respect to option 2, I'm not sure I understand what you mean with the 'interface or object that 1.cod knows about'. can u give me an example?
Offline  
Old 08-19-2009, 05:54 PM   #4
hrbuckley
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Default

If 1.cod was compiled with code to load a class by name from a module you could specify, then you just write that class to return the data you want. Basically both 1.cod and 2.cod have to be written to support the communications. It sounds like this is not the case, and you don't have control over 1.cod. If this is correct that AFAIK you're out of luck.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 08-19-2009, 06:23 PM   #5
kosh
New Member
 
Join Date: Aug 2009
Model: n/a
PIN: N/A
Carrier: Rogers
Posts: 9
Default

Hey, sorry, I probably explained wrong.

Its not that 1.cod is not editable at all. basically, 1.cod is not my application, it is someone elses, but I can tell that person (give him a code guideline) and tell him that so and so is what he needs to do to communicate with my 2.cod that contains the pic and url.

So now, if 1.cod were to call a method from a class in 2.cod, doesnt this mean that 2.cod has to be set up as a library project and 1.cod has to have a dependency on 2.cod (in order to access its modules)?
Offline  
Old 08-19-2009, 07:40 PM   #6
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Default

In order for these two apps to share objects, they'll have to have a shared namespace (like a library).

Sounds to me like you might be better off using global events, and passing the RIM standard objects that are in the shared RIM runtime library.
Offline  
Old 08-20-2009, 08:22 AM   #7
hrbuckley
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Default

Quote:
Originally Posted by kosh View Post

So now, if 1.cod were to call a method from a class in 2.cod, doesnt this mean that 2.cod has to be set up as a library project and 1.cod has to have a dependency on 2.cod (in order to access its modules)?
There are ways to do that while avoiding library semantics, but since this is a collaborative effort what I would recommend is that 1.cod expose a class and method specifically for 2.cod (and others perhaps) to call to set the data in a way similar to the RIM libraries:

My1CodClass.getInstance().setURL(String url);

When 1.cod is compiled a JAR file will be produced. Use that JAR as an external library to compile 2.cod, 3.cod, 4.cod, etc. In this case 1.cod doesn't need any prior knowledge about where the data is going to come from.

If 1.cod must control when the data is fetched, then you can use:
Code:
try {
    Class class = Class.forName("my.cod.DataClass");
    my.cod.DataClass dataClass = class.newInstance();
    String url = dataClass.getUrl();
} catch (ClassNotFoundException e) {
    // Processing for class not found, for example if 2.cod is not loaded on the device.
}
In this case 1.cod and 2.cod would have to share the definition of my.cod.DataClass.

I've used both of these methods.

You could also use the RuntimeStore and global events as suggested above
__________________
My other Blackberry is a PlayBook.
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


FANUC Servo Amplifier A06B-6240-H208 picture

FANUC Servo Amplifier A06B-6240-H208

$3199.00



MITSUBISHI Amplifier MR-J2S-200B MRJ2S200B AC Servo Drive New in box picture

MITSUBISHI Amplifier MR-J2S-200B MRJ2S200B AC Servo Drive New in box

$463.00



1pcs Fanuc Servo Amplifier A06B-6077-H002 New by DHL or EMS picture

1pcs Fanuc Servo Amplifier A06B-6077-H002 New by DHL or EMS

$1089.00



 MITSUBISHI Amplifier MITSUBISHI MR-J2S-200B MITSUBISHI MRJ2S200B AC Servo Drive picture

MITSUBISHI Amplifier MITSUBISHI MR-J2S-200B MITSUBISHI MRJ2S200B AC Servo Drive

$485.00



Honeywell R7849 A 1023 Ultraviolet Amplifier NEW picture

Honeywell R7849 A 1023 Ultraviolet Amplifier NEW

$186.59



3U081 DELTA TAU AMPLIFIER 1-AXIS PWM 230 VAC INPUT  picture

3U081 DELTA TAU AMPLIFIER 1-AXIS PWM 230 VAC INPUT

$401.39







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.