[android-developers] Re: Obtaining Name of Object Reference
Object objRef = new Object(); String nameOfObjRef = objRef; this is what I need returned. Is this possible? On Nov 3, 10:11 am, Kumar Bibek coomar@gmail.com wrote: name of an object reference? On Wed, Nov 3, 2010 at 10:37 PM, Darkside Android darksideandr...@gmail.com wrote: Object getThisObjName= new Object(); I'd like to get the name of an object reference. Is this possible via reflection in Android? -- 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.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com -- 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] Re: Obtaining Name of Object Reference
I don't think so. On Wed, Nov 3, 2010 at 11:17 PM, Darkside Android darksideandr...@gmail.com wrote: Object objRef = new Object(); String nameOfObjRef = objRef; this is what I need returned. Is this possible? On Nov 3, 10:11 am, Kumar Bibek coomar@gmail.com wrote: name of an object reference? On Wed, Nov 3, 2010 at 10:37 PM, Darkside Android darksideandr...@gmail.com wrote: Object getThisObjName= new Object(); I'd like to get the name of an object reference. Is this possible via reflection in Android? -- 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.comandroid-developers%2bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com -- 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.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com -- 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] Re: Obtaining Name of Object Reference
Suppose this was possible, what would you do with the name as a string? -- Kostya Vasilyev -- http://kmansoft.wordpress.com 03.11.2010 20:48 пользователь Darkside Android darksideandr...@gmail.com написал: Object objRef = new Object(); String nameOfObjRef = objRef; this is what I need returned. Is this possible? On Nov 3, 10:11 am, Kumar Bibek coomar@gmail.com wrote: name of an object reference? On Wed, Nov 3, 2010 at 10:37 PM, Darkside Android darksideandr...@gmail.com wrote: Object getThisObjName= new Object(); I'd like to get the name of an object re... android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en... Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com -- You received this message because you are subscribed to the Google Groups Android Developers ... -- 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] Re: Obtaining Name of Object Reference
In general, this is not possible. Consider for example: Object obj1 = new Object(); Object obj2 = obj1; Both obj1 and obj2 are references to the same object. In this case, what object name would you want? Perhaps if you explain what you are trying to do we can help. -- 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] Re: Obtaining Name of Object Reference
It depends actually. If you have a Class, and you want to know the field/method names of a class. TestClass obj = new TestClass(); ClassTestClass classRef = (ClassTestClass) obj.getClass(); Field[] fields = classRef.getFields(); for(Field field: fields){ System.out.println(field.getName()); } This will print a list of fields names in this class. But, if you just have a reference, and you want to printout it's string value, it's not possible. 2010/11/3 Kostya Vasilyev kmans...@gmail.com Suppose this was possible, what would you do with the name as a string? -- Kostya Vasilyev -- http://kmansoft.wordpress.com 03.11.2010 20:48 пользователь Darkside Android darksideandr...@gmail.com написал: Object objRef = new Object(); String nameOfObjRef = objRef; this is what I need returned. Is this possible? On Nov 3, 10:11 am, Kumar Bibek coomar@gmail.com wrote: name of an object reference? On Wed, Nov 3, 2010 at 10:37 PM, Darkside Android darksideandr...@gmail.com wrote: Object getThisObjName= new Object(); I'd like to get the name of an object re... android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en... Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com -- You received this message because you are subscribed to the Google Groups Android Developers ... -- 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.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com -- 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: Obtaining Name of Object Reference
You're not making much sense. If you want to know the name of objRef you can just include String nameOfObjRef = objRef; in your code. Won't do you much good, of course, since there's nothing (outside of some complex debugging scenarios) you can do with it. You CAN find the names of fields (and methods) in a class, via reflections. And of course you can easily get the class name of an object with getClass().getName(). On Nov 3, 12:47 pm, Darkside Android darksideandr...@gmail.com wrote: Object objRef = new Object(); String nameOfObjRef = objRef; this is what I need returned. Is this possible? On Nov 3, 10:11 am, Kumar Bibek coomar@gmail.com wrote: name of an object reference? On Wed, Nov 3, 2010 at 10:37 PM, Darkside Android darksideandr...@gmail.com wrote: Object getThisObjName= new Object(); I'd like to get the name of an object reference. Is this possible via reflection in Android? -- 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.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com -- 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: Obtaining Name of Object Reference
I think he is looking for reflecting into the class like kumar has posted! Which I believe might me overkill if u just want to get class name you migt be able to just do a tostring since a lot of classes suport it and return there class name as such. On Nov 3, 1:07 pm, Darkside Android darksideandr...@gmail.com wrote: Object getThisObjName= new Object(); I'd like to get the name of an object reference. Is this possible via reflection in Android? -- 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: Obtaining Name of Object Reference
But using reflections to get field names is much different from (somehow) obtaining the names of auto variables in a method. For the latter you could probably parse the class file to extract the debug symbol table (not an easy task), if working within a regular JVM, but it's likely to be even more difficult in the Android VM. On Nov 3, 1:48 pm, Byron Penner bapenner...@gmail.com wrote: I think he is looking for reflecting into the class like kumar has posted! Which I believe might me overkill if u just want to get class name you migt be able to just do a tostring since a lot of classes suport it and return there class name as such. On Nov 3, 1:07 pm, Darkside Android darksideandr...@gmail.com wrote: Object getThisObjName= new Object(); I'd like to get the name of an object reference. Is this possible via reflection in Android? -- 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