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
For goodness sake let the guy ask his question! A Forum is supposed to provide help and definitely should not scare users away or make them too afraid to ask any question.
I am concerned that a lot of newbies are already discouraged from asking a simple (or even not so simple) question. So what if a question gets asked more than once?!
I fully understand his response in Italian. I had the same sentiment when I read what you wrote. My experience is that you can sometimes spend days seaching this huge forum and still not find what you are really looking for. A quick question and a rapid response from a knowledgeable Forum member can save a lot of time and might make this Forum more lively like it used to be years ago... At least that is my opinion. Does this Forum really have to be so strict and "tight" ? Is it really necessary to tell people off with phrases like "The Forum search is working"? Please let's make this forum more vivid in stead of it now being down to less than a dozen (often very complex) entries a day. Give newbies and also others a chance to learn B4A and don't push them in a corner by making them feel ignorant, sloppy for not searching long enough in the forum and blaming them for being inexperienced! Let's all realize that it is extremely difficult to board this B4A train that has been running for nearly 10 years at ever increasing speed. Take a look at the kind of questions that were asked in this forum 5 years ago and compare them to the topics that are being addressed now.
To be honest, I don't understand more than half the questions that I read nowadays in this Forum (and I have been using B4A since 2012) and I would love to occasionally respond to a question that at least I cán answer...
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
Top