Tips for identifying tablet devices using the deviceDetector module in AngularJS

Having an issue with a Samsung Tablet. I need to display certain content for mobile devices, but not tablets.

Device detection results:
- isMobile(): true
- isTablet(): false

Here is the detailed data from the module:

{"raw":{"userAgent":"Mozilla/5.0 (Linux; Android 4.4.2; es-us; SAMSUNG SM-T230NU Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Safari/537.36","os":{"windows":false,"mac":false,"ios":false,"android":true,"linux":true,"unix":false,"firefox-os":false,"chrome-os":false,"windows-phone":false,"ps4":false,"vita":false,"unknown":false},"browser":{"chrome":true,"firefox":false,"safari":true,"opera":false,"ie":false,"ms-edge":false,"ps4":false,"vita":false,"unknown":false},"device":{"android":true,"ipad":false,"iphone":false,"ipod":false,"blackberry":false,"firefox-os":false,"chrome-book":false,"windows-phone":false,"ps4":false,"vita":false,"unknown":false},"os_version":{"windows-3-11":false,"windows-95":false,"windows-me":false,"windows-98":false,"windows-ce":false,"windows-2000":false,"windows-xp":false,"windows-server-2003":false,"windows-vista":false,"windows-7":false,"windows-8-1":false,"windows-8":false,"windows-10":false,"windows-phone-7-5":false,"windows-phone-8-1":false,"windows-phone-10":false,"windows-nt-4-0":false,"unknown":false}},"os":"android","browser":"chrome","device":"android","os_version":"unknown","browser_version":"28.0.1500.94"}

Appreciate any help provided.

Answer №2

Encountered an issue on Tablets running Android OS where ng-device-detector displayed the same information for both Android Tablets and Android Phones. After searching for a solution, I discovered that all Smartphones have the string "Mobile" in their userAgent, while tablets do not.

Check out this list of userAgents for smartphones.

To address this issue, I implemented the following function to replace the existing "isMobile" function in ng-device-detector:

deviceDetector.isMobile = function(){
    var ua = deviceDetector.raw.userAgent;
    return ua.match(/Mobile/i);
}

Thank you all for your help. Apologies for my English, as Spanish is my primary language.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to easily extract all values associated with a particular key in a nested JSON using JavaScript?

I have a JSON structure that looks like this: [ { cells: [ { id: "1", cellType: 3, widget: { id: 1, description: "myDesc"} }, { id: "2", cellType: 4, widget: { id: 2, description: "myDesc2"} } ] }, { cells: [ { id: "3", c ...

cheerio scraping results in an array that is devoid of any data

Struggling to extract data from a website with the URL https://buff.163.com/market/csgo#tab=buying&page_num=1 using request-promise and cheerio. Check out my code snippet below: const request = require('request-promise'); const cheerio = requ ...

Consistently shifting the Aframe camera towards the focal point

Is there a way to continuously adjust the view of my Aframe scene based on the current viewing direction? It seems like there are two key components needed for this: (1) obtaining the current viewing direction in the correct format, and (2) creating and u ...

Display chosen preferences in an Angularjs dropdown alongside additional options

I'm currently developing a blogging software and have implemented an AngularJS dropdown for selecting post terms. Here's the code: <select multiple="multiple" name="terms" ng-model="post.data.attributes.term_ids" required> ...

What is the method to retrieve the value from $.get()?

After searching on stackoverflow, I was unable to locate a solution to my issue and am currently unable to comment for further assistance. The dilemma I face involves extracting a return value from an asynchronous method to pass it onto another function: ...

odd appearance when objects make contact with one another

I am encountering a peculiar issue with my threejs objects in a scene. Whenever they get near each other or touch, I notice strange triangular artifacts forming at the borders of the objects, as shown in the image below. The renderer being used is THREE.W ...

I must display the output in the proper format as illustrated below

angular.forEach(caseChangeRecord, function(change, key) { if (caseChangeRecord != 'undefined') { body += change.fieldName + ' : ' + change.newValue; } }); Expected Display Output: A:B A:B A:B ...

JQuery Validation - Implementing real-time validation on button click instead of form submission

I am currently attempting to use JQuery Validation with WebForms/html. I have simplified the HTML code below, displaying only the necessary elements: <input id="txtEmail"/> <input id="txtTicketID"/> <a id="create" href="#">Create a new t ...

How can I implement a redirect function for Carousel image clicks in a React project?

I am working on a React project that includes Carousel from the 'react-responsive-carousel' npm package. I am looking to implement a functionality where clicking on the images in the Carousel will redirect to another component. How can this be ac ...

I'm interested in learning the best way to insert the images from this JSON file into the corresponding div elements

I have completed developing a clone of an Instagram web page. Although I can retrieve data from the JSON file and insert it into the <img> tag, I am facing difficulty in displaying each image above its respective .below-image div with consistent spac ...

Utilizing AJAX to submit a combination of text fields and files in an HTML form

Just starting out with AJAX and JQuery, I'm curious if it's possible to send data from an HTML form, including a text file and two separate text boxes, via an AJAX request. So far, I've managed to send the data from the text boxes but not th ...

Filter prices (minimum and maximum) using a dropdown menu in asp.net core

Struggling to filter prices using javascript and asp.net core, I've written a lot of javascript code that isn't quite cutting it. I'm wondering if there's a simpler way to achieve this, perhaps with jquery or in c#? If anyone has any ...

Tips for transferring information from a form to your email address

I am trying to find a way to automatically send form data to my email without the user having to open their inbox. I attempted to use the "mailto" function but it didn't work as desired, still opening the email box. Here is the script I tried: functio ...

What is the best way to ensure that my multiple choice code in CSS & JS only allows for the selection of one option at a time? Currently, I am able

I'm currently facing a small issue that I believe has a simple solution. My knowledge of Javascript is limited, but I am eager to improve my skills in coding for more visually appealing websites. My problem lies in the code snippet below, where I am ...

Dealing with Vue's performance problems when using input type color and v-model

I am encountering a problem with setting the v-model on an input of type color. Whenever I change the color, there is a noticeable drop in frame rate and the application's FPS spikes from 60 to 3. You can see it reflected in the Vue performance graph ...

Shifting the data label on a pie chart in ApexCharts - what's the trick?

I need help adjusting my data labels to make them more readable by moving them inward. It would be perfect if there is a way to dynamically center them within the slice. https://i.stack.imgur.com/bCelP.png Despite reading the documentation and trying dif ...

passing JSON data using JavaScript or jQuery

I have a JSON snippet that I need to parse using JavaScript or jQuery and convert into variables: name and meetup. Can you help me with this? Below is the JSON code: { "MYID": 1, "module": [ { "name": "Manchester", ...

Convert a two-column layout on the web into a single-column layout for mobile devices, featuring dynamic

Is there a way to style this diagram with CSS that will work on IE11 and all major browsers? It seems like Flexbox doesn't support dynamic height. Do I need separate left and right columns for larger viewports and no columns for smaller viewports? ...

What is the method for inserting a clickable link into a data-image line of code using CSS3?

Recently, I delved into the world of CSS and am still getting the hang of it, Below is a snippet of code that I have been working on, <div id='ninja-slider'> <ul> <li> <div data-image="images/md/1.j ...

The external IP lookup service is showing a 404 error code

While attempting to retrieve the user's IP address from an external IP service, everything works smoothly on a PC browser but returns a 404 error on the device. Even after trying alternative external IP services, the same issue persists on the device. ...