PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 25 → WM - Saber se o aplicativo esta rodando em um tablet e nao em um celular
WM - Saber se o aplicativo esta rodando em um tablet e nao em um celular
Débuté par adrianoboller, 06 avr. 2015 23:21 - Aucune réponse
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 06 avril 2015 - 23:21
IF isTable() = False
EndProgram()
END

Procedure GLOBAL Java

############################################################################
import android.content.res.Configuration;

// Returns True if the device that runs the application is a tablet
PUBLIC static boolean isTablet(){
RETURN (getApplicationContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}
############################################################################


OU pelo Modelo
modelo is string = getDeviceName()
#############################################################################
Procedure GLOBAL Java

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.*;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
import android.provider.Settings.Secure;

PUBLIC static string getDeviceName() {

string manufacturer = android.os.Build.MANUFACTURER;
string model = android.os.Build.MODEL;
string brand = android.os.Build.BRAND;
string product = android.os.Build.PRODUCT;
string board = android.os.Build.BOARD;
string bootloader = android.os.Build.BOOTLOADER;
string cpu_abi = android.os.Build.CPU_ABI;
string cpu_abi2 = android.os.Build.CPU_ABI2;
string device = android.os.Build.DEVICE;
string display = android.os.Build.DISPLAY;
string fingerprint = android.os.Build.FINGERPRINT;
string hardware = android.os.Build.HARDWARE;
string host = android.os.Build.HOST;
string id = android.os.Build.ID;
string radio = android.os.Build.RADIO;
string serial = android.os.Build.SERIAL;
string tags = android.os.Build.TAGS;
string type = android.os.Build.TYPE;
string user = android.os.Build.USER;

IF (model.startsWith(manufacturer)) {
RETURN (model);
} ELSE {
string MarcaModeloCelular = "manufacturer: " + (manufacturer) + "; model: " + (model) + "; brand: " + (brand) + "; product: " + (product) + "; board:" + (board) + "; bootloader: " + (bootloader) + "; cpu_abi: " + (cpu_abi) + "; cpu_abi2: " + (cpu_abi2) + "; device: " + (device) + "; display: " + (display) + "; fingerprint: " + (fingerprint) + "; hardware: " + (hardware) + "; host: " + (host) + "; id: " + (id) + "; radio: " + (radio) + "; serial: " + (serial) + "; tags: " + (tags) + "; type: " + (type) + "; user: " + (user);

MarcaModeloCelular = MarcaModeloCelular.toUpperCase();

RETURN MarcaModeloCelular;
}
}
#############################################################################


OU pela resolução

Procedure Resolucao()

// Horizontal resolution of the screen
ResHorizRes is int = SysXRes()
gloResHorizRes = ResHorizRes

// Vertical resolution of the screen
ResVertRes is int = SysYRes()
gloResVertRes = ResVertRes

Retorno is string = ResHorizRes +"X"+ ResVertRes

W = gloResHorizRes
H = gloResVertRes
IF H = 1920 AND W = 1080 THEN //s4
gnCentroY = 1530
gnCentroYinitial = 1050
ELSE IF H = 800 AND W = 480 THEN // mini
gnCentroY = 605
gnCentroYinitial = 525
ELSE IF H = 800 AND W = 1280 THEN // tablet 1171 419
gnCentroY = 1070
gnCentroYinitial = 319
END

RESULT(Retorno)