get device model name

Smee

Well-Known Member
Licensed User
Longtime User
Is there a way to get the device & model name of the device that is running the software?
 

gregwa

Member
Licensed User
Longtime User
Yes. By using the Phone Library...

B4X:
Sub GetInfo
   Dim manu As String
   Dim modl As String
   Dim prod As String
   
   manu = phone1.Manufacturer
   modl = phone1.Model
   prod = phone1.Product
   
   Log(manu & " - " & modl & " - " & prod)
   
End Sub

on my Archos tablet returns ...

B4X:
archos - ARCHOS 101G9 - G9A101
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
Thanks for the quick reply. sorry i posted too soon. What i need is to be able to get the info without using the phone library.

I get the device id using code with the reflection library and i was hoping for a similar solution

Thanks again for your solution
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
Upvote 0

gregwa

Member
Licensed User
Longtime User
Erel would be the end all on this, but I don't think you can condemn the entire phone library because of one call. In addition, I do not believe that my example uses the Get device call.

I think you missed the part that the example was run on a tablet. In the thread you reference, it states "It doesn't work on devices without phone functionality".

IMHO, in this case I believe you are concerned about nothing. But I will defer to Erel for any corrections to my statements.

Gregwa
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
don't mis-understand me, i am not condemming the library as such, but why add a library if it is not really necessary. If i can get the same info with a small amount of code i would prefer to do that rather than add an entire library for 1 call. if i cannot then so be it
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Upvote 0

gregwa

Member
Licensed User
Longtime User
Smee,
You do bring up a valid question here and one that I will have to bow to others, like Erel, with more B4A knowledge than I have at this moment.

In python, it is usually suggested you don't do

B4X:
import sys

just to get the exit routine. It is better to do something like this

B4X:
from sys import exit

because of the fact that every routine is brought in when you use the "import everything" syntax.

Now, I can fumble my way through Java kinda like I can fumble my way through spanish (muy malo).

Maybe someone can discuss the ramifications of importing an entire library when only one (or three) call(s) are used.

I can, however, tell you that the sample code that I provided yesterday does not show the phone permissions when you look at the app under Settings | Apps. The App memory usage shows 632KB from there as well. If I remove the calls and the Phone library, it shows the memory usage is only 560KB. The APK without the phone library is 239K compared to 260K.

So, you need to be the judge. Is 72KB in memory enough to force you to find a way to write your own routines?

For me, under "normal" circumstances, it isn't.
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
I quite agree. However the size inflates every time a lib is used for just one call.

Thanks for your input and code
 
Upvote 0
Top