Re: [android-developers] Reading from another app
Latimerius, Do you mean something like this? (I ripped this from another site) Resources res = context.getPackageManager().getResourcesForApplication(com.example.foo) I was doing something very similar already (posted below), though thought it was a bit of a hack. final String packName = com.jash.cp_source_two; String mDrawableName = a1; try { PackageManager manager = getPackageManager(); Resources resources = manager.getResourcesForApplication(packName); int mDrawableResID = resources.getIdentifier(mDrawableName, drawable,packName); Drawable myDrawable = resources.getDrawable( mDrawableResID ); if( myDrawable != null ) { image = (ImageView) findViewById(R.id.imageView1); image.setImageDrawable(myDrawable ); } } catch (PackageManager.NameNotFoundException e) { Toast.makeText(getBaseContext(), error = +e, Toast.LENGTH_LONG).show(); } Is there any reason to use your method over what I already had? Also, July was a big month and Mark Murphy posts a lot! Do you happen to remember roughly what the topic was to help narrow down the search ;) Thanks a great deal for this. Russ On Wednesday, January 2, 2013 10:42:23 AM UTC, latimerius wrote: On Wed, Jan 2, 2013 at 2:20 AM, Russell Wheeler russellpe...@gmail.com wrote: Latimerius, So how do you directly access them from the assets folder? You have to know the name of the package whose images you want to use but that shouldn't be a problem in your case if I understand correctly. Then you just pass it to createPackageContext() which you call on one of your Activities (I use the main one but I guess it probably doesn't matter much which one you pick) to retrieve a Context of the package containing images. After that, everything works the same as when working with this package's resources - you call getResources() or getAssets() on the Context etc. Doing it this way, are the images available to anyone who has root access? i.e. can they steal your images? Then can do that anytime anyway. Everybody seems surprised to learn that (I know I was!) but anybody can access your assets and resources any time they please with just minor inconvenience, and they DON'T need root for that. (There was a thread about this on this group last July I think, Mark Murphy had some insights back then so look it up if you're interested.) Why do you use assets? For ease, or for some other reason? I thought it would be better to have them in the res folders so that the diff screen sizes still get used, e.g. ldpi/hdpi etc folders? I use assets because the program I work on is a game, or a toy, which uses custom rules to adapt to different screen sizes and densities. We started off using resources but quickly found out that Android's built-in scaling etc. was just ruining our art and throwing off our screen layout algorithms. Of course, even if res folders didn't work for us with our special needs, they can still work splendid for you. In that case, just go for res, I have no first-hand experience with that but I don't see any reason why it shouldn't work. -- 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
Re: [android-developers] Reading from another app
RichardC looking through my phone using astro file manager, I can't find any apps that have been installed? Is that because I am not rooted? What folder would/should they be in if I can see them? Or do you mean the apk is readable before its installed? In that case, how do you save an apk from Google play without it installing? Thanks for helping Russ -- 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
Re: [android-developers] Reading from another app
RichardC looking through my phone using astro file manager, I can't find any apps that have been installed? Is that because I am not rooted? What folder would/should they be in if I can see them? Or do you mean the apk is readable before its installed? In that case, how do you save an apk from Google play without it installing? Thanks for helping Russ -- 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
Re: [android-developers] Reading from another app
On Wed, Jan 2, 2013 at 2:20 AM, Russell Wheeler russellpeterwhee...@gmail.com wrote: Latimerius, So how do you directly access them from the assets folder? You have to know the name of the package whose images you want to use but that shouldn't be a problem in your case if I understand correctly. Then you just pass it to createPackageContext() which you call on one of your Activities (I use the main one but I guess it probably doesn't matter much which one you pick) to retrieve a Context of the package containing images. After that, everything works the same as when working with this package's resources - you call getResources() or getAssets() on the Context etc. Doing it this way, are the images available to anyone who has root access? i.e. can they steal your images? Then can do that anytime anyway. Everybody seems surprised to learn that (I know I was!) but anybody can access your assets and resources any time they please with just minor inconvenience, and they DON'T need root for that. (There was a thread about this on this group last July I think, Mark Murphy had some insights back then so look it up if you're interested.) Why do you use assets? For ease, or for some other reason? I thought it would be better to have them in the res folders so that the diff screen sizes still get used, e.g. ldpi/hdpi etc folders? I use assets because the program I work on is a game, or a toy, which uses custom rules to adapt to different screen sizes and densities. We started off using resources but quickly found out that Android's built-in scaling etc. was just ruining our art and throwing off our screen layout algorithms. Of course, even if res folders didn't work for us with our special needs, they can still work splendid for you. In that case, just go for res, I have no first-hand experience with that but I don't see any reason why it shouldn't work. -- 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
Re: [android-developers] Reading from another app - resources/assets (Take 2!)
Using the package name and a resource ID you can load resources from another APK. That's how Launcher loads icons, strings and widget resources for instance. All the APIs you need are in the Resources class if I recall properly. On Jan 1, 2013 5:25 PM, Russell Wheeler russellpeterwhee...@gmail.com wrote: As my previous question seems to have got hijacked by someone else I'll ask again, and hopefully get additional responses. I have included my original question plus latimerius' reply, and then my subsequent reply... On Tuesday, January 1, 2013 9:55:49 PM UTC, latimerius wrote: On Tue, Jan 1, 2013 at 6:08 PM, Russell Wheeler russellpe...@gmail.com wrote: If I wish to use images stored in another app, that I've written, what is the best way to do this? Content provider or directly accessing the res folder? I do almost the same, except that my images are in the assets/ directory, and accessing it directly has worked well for me. On Wednesday, January 2, 2013 1:20:30 AM UTC, Russell Wheeler wrote: Latimerius, So how do you directly access them from the assets folder? Doing it this way, are the images available to anyone who has root access? i.e. can they steal your images? Why do you use assets? For ease, or for some other reason? I thought it would be better to have them in the res folders so that the diff screen sizes still get used, e.g. ldpi/hdpi etc folders? Thanks for asking, not sure quite how this topic has got off of my control?!?! haha Russ -- 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 -- 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] Reading from another app
If I wish to use images stored in another app, that I've written, what is the best way to do this? Content provider or directly accessing the res folder? Thanks in advance Russ -- 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
Re: [android-developers] Reading from another app
On Tue, Jan 1, 2013 at 6:08 PM, Russell Wheeler russellpeterwhee...@gmail.com wrote: If I wish to use images stored in another app, that I've written, what is the best way to do this? Content provider or directly accessing the res folder? I do almost the same, except that my images are in the assets/ directory, and accessing it directly has worked well for me. -- 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
Re: [android-developers] Reading from another app
Latimerius, So how do you directly access them from the assets folder? Doing it this way, are the images available to anyone who has root access? i.e. can they steal your images? Why do you use assets? For ease, or for some other reason? I thought it would be better to have them in the res folders so that the diff screen sizes still get used, e.g. ldpi/hdpi etc folders? Thanks for asking, not sure quite how this topic has got off of my control?!?! haha Russ On Tuesday, January 1, 2013 9:55:49 PM UTC, latimerius wrote: On Tue, Jan 1, 2013 at 6:08 PM, Russell Wheeler russellpe...@gmail.comjavascript: wrote: If I wish to use images stored in another app, that I've written, what is the best way to do this? Content provider or directly accessing the res folder? I do almost the same, except that my images are in the assets/ directory, and accessing it directly has worked well for me. -- 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] Reading from another app - resources/assets (Take 2!)
As my previous question seems to have got hijacked by someone else I'll ask again, and hopefully get additional responses. I have included my original question plus latimerius' reply, and then my subsequent reply... On Tuesday, January 1, 2013 9:55:49 PM UTC, latimerius wrote: On Tue, Jan 1, 2013 at 6:08 PM, Russell Wheeler russellpe...@gmail.com wrote: If I wish to use images stored in another app, that I've written, what is the best way to do this? Content provider or directly accessing the res folder? I do almost the same, except that my images are in the assets/ directory, and accessing it directly has worked well for me. On Wednesday, January 2, 2013 1:20:30 AM UTC, Russell Wheeler wrote: Latimerius, So how do you directly access them from the assets folder? Doing it this way, are the images available to anyone who has root access? i.e. can they steal your images? Why do you use assets? For ease, or for some other reason? I thought it would be better to have them in the res folders so that the diff screen sizes still get used, e.g. ldpi/hdpi etc folders? Thanks for asking, not sure quite how this topic has got off of my control?!?! haha Russ -- 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
Re: [android-developers] Reading from another app
On Wednesday, January 2, 2013 1:20:30 AM UTC, Russell Wheeler wrote: Latimerius, So how do you directly access them from the assets folder? Doing it this way, are the images available to anyone who has root access? i.e. can they steal your images? APKs are world readable Why do you use assets? For ease, or for some other reason? I thought it would be better to have them in the res folders so that the diff screen sizes still get used, e.g. ldpi/hdpi etc folders? Thanks for asking, not sure quite how this topic has got off of my control?!?! haha Russ On Tuesday, January 1, 2013 9:55:49 PM UTC, latimerius wrote: On Tue, Jan 1, 2013 at 6:08 PM, Russell Wheeler russellpe...@gmail.comwrote: If I wish to use images stored in another app, that I've written, what is the best way to do this? Content provider or directly accessing the res folder? I do almost the same, except that my images are in the assets/ directory, and accessing it directly has worked well for me. -- 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