Android Question Check if device have touch screen or not

dagodom

Member
Licensed User
Longtime User
Hi, there is some code to check If device have or not touch screen.
Thank you
 

Biswajit

Active Member
Licensed User
Longtime User
  1. Use the forum search.
  2. If there is no thread/post regarding your query, then
  3. Use google to check if it's actually possible or not.
  4. If possible search for the relevant code.
  5. Use the forum search to search for the functions or methods used in that code.
  6. If there is no answer to your query then
  7. Try to post the code or link to that code. To help others to convert it to B4A.

For example:
  1. I searched in this forum
  2. I didn't find it.
  3. I searched in the google
  4. Got the answer from the first result.
  5. I searched in this forum for hasSystemFeature (got from point 4)
  6. I found a post regarding that function.
So basically you can check if the device has a touch screen or not as follows

B4X:
Sub HasFeature (Feature As String) As Boolean
   Dim ctxt As JavaObject
   ctxt.InitializeContext
   Return ctxt.RunMethodJO("getPackageManager", Null).RunMethod("hasSystemFeature", Array(Feature))
End Sub


If HasFeature("android.hardware.touchscreen") Then
    Log("Device has a touch screen")
End if
 
Upvote 0

Biswajit

Active Member
Licensed User
Longtime User
Don't get me wrong. Neither I asked him to solve his problem himself, nor I discouraged him from asking a question. I just told him how he can find the answer quickly. I would have just asked him to search in the forum/google instead as an example I showed him how did I find out the answer to this question. As a developer, I think its good to know how to search for a problem on the internet. Not all the languages or frameworks have a good forum. Sometimes it may happen that something is not working, just for you or that problem occurred to few developers. In that case you need to split the question and search part by part. What if he wants an urgent solution but there is no one up to help him (as we know its a global forum and not all countries have the same time).

I never discouraged anyone. If there is a solution I help them whenever I get time. I have posted a Socket.IO library last year but I lost the source code. A few days back a very new user asked me if I can add a query parameter functionality. I asked him to wait for few days and build that library again from scratch.

I fully understand his response in Italian.
And FYI I know what he replied in Italian.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…