[android-developers] Re: Problem Using Jar File

2009-08-28 Thread Atif Gulzar
Thanks Mark, It works, I will look into it how to optimize it.


--
Best Regards,
Atif Gulzar

I  Unicode, ɹɐzlnƃ ɟıʇɐ



On Fri, Aug 28, 2009 at 1:52 PM, Mark Murphy wrote:

>
> > But my jar file is referring number of layouts (about 10) and these
> > layouts contains number of ids (about 100). It is difficult to pass so
> > many ids as parameters.
>
> You can try Resources#getIdentifier(). If you get this working, please
> cache your results, as these lookups are apparently expensive ("Note: use
> of this function is discouraged. It is much more efficient to retrieve
> resources by identifier than by name.").
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com
> Android App Developer Books: http://commonsware.com/books.html
>
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Problem Using Jar File

2009-08-28 Thread Mark Murphy

> But my jar file is referring number of layouts (about 10) and these
> layouts contains number of ids (about 100). It is difficult to pass so
> many ids as parameters.

You can try Resources#getIdentifier(). If you get this working, please
cache your results, as these lookups are apparently expensive ("Note: use
of this function is discouraged. It is much more efficient to retrieve
resources by identifier than by name.").

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Problem Using Jar File

2009-08-28 Thread Mark Murphy

>Thanks for your reply.Right now we are not using the R file of
> that project whose jar file is created.Jar file does not contains R files
> of
> that project.So R.layout and R.id's are created in the client project
> where
> i am using jar file.

And that is precisely your problem, if the Java code in the JAR file tries
using R.layout, R.id, and kin.

Go through the Java code that is going into the JAR. Remove all references
to R.layout, R.id, R.drawable, and so on. Augment your API such that those
values are passed in as parameters.

If your Java code in the JAR does not reference R.layout, R.id,
R.drawable, and so on, then your JAR is fine. Do a clean build of your
project (e.g., get rid of the contents of gen/ and bin/), and you should
be OK.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Problem Using Jar File

2009-08-27 Thread Atif

Thanks Mark,

But my jar file is referring number of layouts (about 10) and these
layouts contains number of ids (about 100). It is difficult to pass so
many ids as parameters. We also try to include the R file in jar and
in code we refer this R file as com.mypackage.R.layout.* and
com.mypackage.R.id.* etc.

But still client file look ups its own generated R file.

Any workaround?

Thanks and regards,
Atif Gulzar

On Aug 28, 11:36 am, "Mark Murphy"  wrote:
> >            Thanks for your reply.Right now we are not using the R file of
> > that project whose jar file is created.Jar file does not contains R files
> > of
> > that project.So R.layout and R.id's are created in the client project
> > where
> > i am using jar file.
>
> And that is precisely your problem, if the Java code in the JAR file tries
> using R.layout, R.id, and kin.
>
> Go through the Java code that is going into the JAR. Remove all references
> to R.layout, R.id, R.drawable, and so on. Augment your API such that those
> values are passed in as parameters.
>
> If your Java code in the JAR does not reference R.layout, R.id,
> R.drawable, and so on, then your JAR is fine. Do a clean build of your
> project (e.g., get rid of the contents of gen/ and bin/), and you should
> be OK.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> Android App Developer Books:http://commonsware.com/books.html
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Problem Using Jar File

2009-08-27 Thread Hassan Imtiaz


Hi Mark,
   Thanks for your reply.Right now i am not using the R file
of that project whose jar file is created.Jar file does not contains R
files of that project.So R.layout and R.id's are created in the client
project where i am using jar file.



Regards
Hassan Imtiaz
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Problem Using Jar File

2009-08-27 Thread Atif Gulzar
Hi Mark,

   Thanks for your reply.Right now we are not using the R file of
that project whose jar file is created.Jar file does not contains R files of
that project.So R.layout and R.id's are created in the client project where
i am using jar file.




--
Best Regards,
Atif Gulzar

I  Unicode, ɹɐzlnƃ ɟıʇɐ



On Fri, Aug 28, 2009 at 12:10 AM, Mark Murphy wrote:

>
> > i am facing a problem in using jar file.I have created a jar
> > file and i am trying to use it in another project.I also copy the xml
> > files from res/layout folder of that project whose jar file is created
> > to the res/layout folder of the project in which i am using jar file.I
> > have also listed all the activites of jar in manifest file of that
> > project. But when i call an activity that is inside jar file it loads
> > the wrong xml file.I mean if inside an activity i have setContentview
> > (R.layout.test1) but it loads another file instead of test1.
> >
> > Any Help??
>
> You cannot reference resources by R.layout, R.id, and such from within a
> JAR such as what you have packaged. You need to adjust your API so the
> application reusing your JAR can pass those values in as parameters.
>
> What happens is that even though you copied over the resources, the
> resource IDs (the numbers that R.layout.foo and R.id.bar map to) will be
> different in the new project.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com
> Android App Developer Books: http://commonsware.com/books.html
>
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Problem Using Jar File

2009-08-27 Thread Mark Murphy

> i am facing a problem in using jar file.I have created a jar
> file and i am trying to use it in another project.I also copy the xml
> files from res/layout folder of that project whose jar file is created
> to the res/layout folder of the project in which i am using jar file.I
> have also listed all the activites of jar in manifest file of that
> project. But when i call an activity that is inside jar file it loads
> the wrong xml file.I mean if inside an activity i have setContentview
> (R.layout.test1) but it loads another file instead of test1.
>
> Any Help??

You cannot reference resources by R.layout, R.id, and such from within a
JAR such as what you have packaged. You need to adjust your API so the
application reusing your JAR can pass those values in as parameters.

What happens is that even though you copied over the resources, the
resource IDs (the numbers that R.layout.foo and R.id.bar map to) will be
different in the new project.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---