PROFESSIONAL NEWSGROUPS
WINDEV
,
WEBDEV
and
WINDEV Mobile
Home
|
Recent messages
|
Connect
|
Sign out
|
English
Home
→
WINDEV Mobile 2024
→
Même application pour smartphone et tablette Androïd
Même application pour smartphone et tablette Androïd
Started by Daniel Varrin, Oct., 09 2013 10:19 AM - 3 replies
Connect yourself…
Daniel Varrin
#1
Posted on October, 09 2013 - 10:19 AM
Bonjour,
Est-ce qu'il existe une fonction qui indique les DPI d'un écran? J'ai réalisé une application Androïd pour smartphone. Ensuite j'ai copié le projet et effectuer quelques modifications pour un fonctionnement sur tablette Androïd.
Mon problème est que je ne voudrais pas vendre deux application différentes. Est-il possible d'utiliser des fenêtres de tailles différentes dans un même projet et de détecter à l'exécution la plate-forme cible?
Report
0
0
Said ZIANI
#2
Posted on October, 10 2013 - 12:31 PM
Essaie la fonction suivante renvoie vrai si je suis sur une tablette 7'', faux si sur smartphone
public static boolean EnModeTablette(){
int portrait_width_pixel=Math.min(getActiviteEnCours().getResources().getDisplayMetrics().widthPixels, getActiviteEnCours().getResources().getDisplayMetrics().heightPixels);
int dots_per_virtual_inch=getActiviteEnCours().getResources().getDisplayMetrics().densityDpi;
float virutal_width_inch=portrait_width_pixel/dots_per_virtual_inch;
if (virutal_width_inch<=2){
return false;
}
else{
return true;
}
}
Cordialement
Report
0
0
Saïd ZIANI
#3
Registered member
8 messages
Posted on October, 10 2013 - 12:48 PM
Bonjour,
La procédure suivante te renverra Vrai si tu te trouves sur une tablette 7'' et Faux si tu es sur une smartphone. Tu peux ensuite modifier le test if (virutal_width_inch<=2) si tu es sur une autre tablette.
public static boolean EnModeTablette(){
int portrait_width_pixel=Math.min(getActiviteEnCours().getResources().getDisplayMetrics().widthPixels, getActiviteEnCours().getResources().getDisplayMetrics().heightPixels);
int dots_per_virtual_inch=getActiviteEnCours().getResources().getDisplayMetrics().densityDpi;
float virutal_width_inch=portrait_width_pixel/dots_per_virtual_inch;
if (virutal_width_inch<=2){
return false;
}
else{
return true;
}
}
Cordialement,
Report
0
0
Daniel
#4
Posted on October, 10 2013 - 10:34 PM
Super! Merci beaucoup! Je vais essayer
Report
0
0
→ Go back to WINDEV Mobile 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (earlier versions)
WEBDEV (earlier versions)
WINDEV Mobile (earlier versions)
Reports & Queries
Off-topic
Tools
Français
English
Español
Portuguesa
Close this window
Search type
Only topics
All the messages
Search period
Any time
Past hour
Past 24 hours
Past week
Past month
Past year
Cancel
Preview of your message
Adding an image
Import an image from a URL
Send an image from a file of your disk
Drop a file or click "Browse..."
or
Cancel
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Text