Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810
Accepted Solution

usage and installation of independent library

Hi all.

 

I use a library to carry some data for the Main application and in some cases I need the library uninstalled after using it.

 

But since I deployed the Main app together with the dependant library, I get the

"Error starting APP: Module 'lib' not found" after uninstalling the library.

 

I want it to be uninstalled to release its resources and free up memory (since I already took what I need from it).

 

So the question is:

 

How can I use a library without setting the dependency property, and use DM or OTA provisioning in one packet at the same time ?

 

Thanks.



"Listen carefully, I shall say this only once"
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: usage and installation of independent library

You could create the library and install its COD.


Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: usage and installation of independent library

Thanks for your input on the subject.

 

I am doing that now.

 

Am I missing something ?

 

The compiler (of course) complains if i don't set the dependency of the Main app. It does not recognize the class contained in the library.

But if I do set the dependency everything is OK until I uninstall the library from the device. Then the Main app refuses to start (which makes sense).

 

How can I use a library without setting my Main app's dependencies ?

 

(If I do that, uninstalling the library will not prevent the Main app from running).



"Listen carefully, I shall say this only once"
Developer
Posts: 16,682
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: usage and installation of independent library

this won't be possible. if your only concern is space you could create a second version of the library, containing only empty interfaces instead of all the data.

or you could create a second app that makes the resources available using runtimestore or similar, which could be deleted afterwards without dependency problems.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: usage and installation of independent library

Hmmm...

 

1) "this won't be possible. if your only concern is space you could create a second version of the library, containing only empty interfaces instead of all the data."

 

How should I implement that?

 

The idea is to provision some data in the library. Main App takes the data, writes it to the filesystem and then uninstalls the library thus releasing unnecessary resources.

 

So the library carries the payload and can be dismissed after usage. But the User will later receive another library with new payload.

 

2) "or you could create a second app that makes the resources available using runtimestore or similar, which could be deleted afterwards without dependency problems."

 

I already tried this approach, but I want to remove any constraints posed by the system on the payload app. When using runtime storage, I need the 'interprocess communication' permission, right? It seems quite a mess using a runtime storage since it's a one way communication than. Library is much better approach.

 

 

Is there no way to access a library by searching for class name... or something like that  (that way I would be able to remove the dependency)?

 

Thanks for your interest!



"Listen carefully, I shall say this only once"
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: usage and installation of independent library

I tried several approaches and still no luck.

 

Can something like this work:

 

fClazz = Class.forName("com.xx.bb.library");
InputStream is = fClazz.getResourceAsStream("/libraryData.txt");

 

 

it seems that getResourceAsStream doesn't care about the fClazz part since it never gets any of the Library's data. But if I enter any Main app resource name, the InputStream is correctly initialized :smileysad: !?

 

Any hints about getting

fClazz.getResourceAsStream(String)

work ?



"Listen carefully, I shall say this only once"
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: usage and installation of independent library

Not tried and not sure, just a thought..

 

InputStream is = fClazz.getResourceAsStream("cod://[Module Name]/libraryData.txt");

Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: usage and installation of independent library

Nope :smileysad:

 

thanx for the hint, I tried several variations with it... but none seem to work.



"Listen carefully, I shall say this only once"
Developer
Posts: 19,629
Registered: ‎07-14-2008
My Device: Not Specified

Re: usage and installation of independent library

It is possible to use the Class.forname to detect whether a package (not a cod file) is installed or not and then create instances of classes within that package and then do something like a 'toString()' on the instance to get data out.  I have some code kicking round that does something like this.

 

So, in short, from your non Library cod, you can detect that the Library cod is present and get data from it.

 

Actually you can probably use CodeModuleManager to detect the existence of the cod anyway.

 

That done, the question is how to get your  application to stay alive once the the Library has disappeared?  The only way I have found is to package the two into separate Applications, with separate downloads, or separate alx's.

 

However I'm not convinced you want to remove this library cod.  I presume you are using it to supply installation options.  If you leave it on the device, your user has the option of resetting the configuration to the installation default.  Which can be very useful when debugging.

 

 

Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: usage and installation of independent library

hmm...

 

toString() won't do for .mp3 files, or could it ?

 

Let me explain, in short:

 

1) My Main app is the work horse.

2) On first install and later on I provision some new settings to it

 

The reason for using this Application (work) + library (settings) scheme is because

sometimes settings are quite large (>1MB) and I write them to the File system but they are still consuming valuble memory space because I cannot release them as resources.

 

So I thought: put it in a separate library. Hmm... I remembered, but will the library also consume memory ? Well why don't I uninstall the library after using it...

Then my app won't start because it's bulit as a dependency... and so on.

 

My biggest problem is the fact that i need 1) and 2) but at the same time I want to minimize memory footprint since all the data is on file system anyway.

 

Sorry for the long post.

 

Thanks for the effort.



"Listen carefully, I shall say this only once"