PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → LanceAppli ne fonctionne pas
LanceAppli ne fonctionne pas
Débuté par erbl, 25 sep. 2020 14:30 - 15 réponses
Membre enregistré
201 messages
Popularité : +6 (10 votes)
Posté le 25 septembre 2020 - 14:30
Salut tout le monde, je ne comprends pas sur windev mobile 25 le lance appli semble ne pas fonctionner !
// Lance l'application
ToastAffiche("lancement ",toastCourt,cvMilieu,chCentre)
bLancé = LanceAppli("com.android.chrome")
ToastAffiche("résultat lancement "+bLancé,toastCourt,cvMilieu,chCentre)
SI ErreurDétectée ALORS
ToastAffiche("erreur "+ErreurInfo(),toastCourt,cvMilieu,chCentre)
FIN

ça affiche lancement et c'est tout, l'application (chrome là pour l'exemple mais pareil avec tout) n'est pas lancée

--
Ce n'est pas l'outil le plus important mais la manière de s'en servir
Membre enregistré
201 messages
Popularité : +6 (10 votes)
Posté le 23 novembre 2020 - 14:24
Problème toujours présent, pas de solutions?

--
Ce n'est pas l'outil le plus important mais la manière de s'en servir
Membre enregistré
164 messages
Popularité : +10 (10 votes)
Posté le 23 novembre 2020 - 17:00
Via l'activitymanager de l'adb la commande est :
adb shell am start -n com.android.chrome/com.google.android.apps.chrome.Main


Je te suggèrerai d'essayer avec "com.android.chrome/com.google.android.apps.chrome.Main"

--
https://github.com/reuniware
https://stackoverflow.com/users/10922639/kotlinisland
Membre enregistré
164 messages
Popularité : +10 (10 votes)
Posté le 23 novembre 2020 - 17:05
J'ai aussi trouvé le code Java suivant pour faire cela :
https://stackoverflow.com/questions/26207708/open-chrome-app-and-inject-javascript

Intent intent = new Intent("android.intent.action.MAIN");
                            intent.setComponent(ComponentName.unflattenFromString("com.android.chrome/com.android.chrome.Main"));
                            intent.addCategory("android.intent.category.LAUNCHER");
                            intent.setData(Uri.parse("http://www.twitch.tv/insomniacgamers12345/hls"));
                            startActivity(intent);


--
https://github.com/reuniware
https://stackoverflow.com/users/10922639/kotlinisland
Membre enregistré
201 messages
Popularité : +6 (10 votes)
Posté le 23 novembre 2020 - 18:10
Merci beaucoup
j'ai également un code java mais qui ne fonctionne pas non plus, étrange
à priori le lanceAppli fonctionnait avant que je ne modifie l'appli (version windev mobile 22 ou 24) mais j'ai pas du tout touché à cette partie là
Activity activity = getActiviteEnCours();
Intent intent = activity.getPackageManager().getLaunchIntentForPackage(sPackageName);
if (intent != null)
{
try
{
activity.startActivity(intent);
}
catch (ActivityNotFoundException err)
{
appelProcedureWL("ToastAffiche","Echec de [startActivity]");
}
}
else
{
appelProcedureWL("ToastAffiche","getPackageManager (" + sPackageName + ") est NULL");
}

--
Ce n'est pas l'outil le plus important mais la manière de s'en servir
Membre enregistré
1 603 messages
Popularité : +64 (70 votes)
Posté le 24 novembre 2020 - 08:09
Bonjour,

Rechercher dans les FAQ : LanceAppli
Il y a peut-être une explication...

--
Cordialement
François
Membre enregistré
201 messages
Popularité : +6 (10 votes)
Posté le 24 novembre 2020 - 08:42
François SCHAAL a écrit :
Bonjour,

Rechercher dans les FAQ : LanceAppli
Il y a peut-être une explication...

--
Cordialement
François


Merci pour le conseil mais en cherchant lanceAppli j'ai rien d'interessant dans la FAQ

--
Ce n'est pas l'outil le plus important mais la manière de s'en servir
Membre enregistré
1 603 messages
Popularité : +64 (70 votes)
Posté le 24 novembre 2020 - 09:40
Oui j'ai confondu LanceAppliAssociée et lanceAppli
Je ne vois pas trop l'utilité du lanceAppli pour lancer Chrome par exemple...

--
Cordialement
François
Membre enregistré
164 messages
Popularité : +10 (10 votes)
Posté le 24 novembre 2020 - 09:56
Le code Java que j'ai donné hier fonctionne bien, je l'ai testé.

--
https://github.com/reuniware
https://stackoverflow.com/users/10922639/kotlinisland
Membre enregistré
201 messages
Popularité : +6 (10 votes)
Posté le 24 novembre 2020 - 10:02
François SCHAAL a écrit :
Oui j'ai confondu LanceAppliAssociée et lanceAppli
Je ne vois pas trop l'utilité du lanceAppli pour lancer Chrome par exemple...

--
Cordialement
François

C'était pour tester avec une appli au pif, le but c'est de lancer une autre application à moi

--
Ce n'est pas l'outil le plus important mais la manière de s'en servir
Membre enregistré
201 messages
Popularité : +6 (10 votes)
Posté le 24 novembre 2020 - 10:03
KotlinIsland a écrit :
Le code Java que j'ai donné hier fonctionne bien, je l'ai testé.

--
https://github.com/reuniware
https://stackoverflow.com/users/10922639/kotlinisland

je sais pas ce qui n'allait pas avec mon code java
ça fonctionne avec celui ci merci à tous

Context myContext = getContexteApplication();
String NomApp = sPackageName; // change it with the package you want to open
PackageManager manager;
//FLAG_ACTIVITY_NEW_TASK
Intent i = new Intent(Intent.ACTION_MAIN);
manager = myContext.getPackageManager();
i = manager.getLaunchIntentForPackage(NomApp);
i.addCategory(Intent.CATEGORY_DEFAULT);
myContext.startActivity(i);


--
Ce n'est pas l'outil le plus important mais la manière de s'en servir
Membre enregistré
164 messages
Popularité : +10 (10 votes)
Posté le 24 novembre 2020 - 10:08
Autant pour moi, voici le code qui fonctionne bien :

import android.content.Intent;
import android.content.ComponentName;
import android.net.Uri;
public static void StartChrome()
{
Intent intent = new Intent("android.intent.action.MAIN");
intent.setComponent(ComponentName.unflattenFromString("com.android.chrome/com.google.android.apps.chrome.Main"));
intent.addCategory("android.intent.category.LAUNCHER");
intent.setData(Uri.parse("https://ntic974.blogspot.com"));
getActiviteEnCours().startActivity(intent);
}


;)

--
https://github.com/reuniware
https://stackoverflow.com/users/10922639/kotlinisland
Membre enregistré
164 messages
Popularité : +10 (10 votes)
Posté le 24 novembre 2020 - 10:10
erbl a écrit :
KotlinIsland a écrit :
Le code Java que j'ai donné hier fonctionne bien, je l'ai testé.

--
https://github.com/reuniware
https://stackoverflow.com/users/10922639/kotlinisland

je sais pas ce qui n'allait pas avec mon code java
ça fonctionne avec celui ci merci à tous

Context myContext = getContexteApplication();
String NomApp = sPackageName; // change it with the package you want to open
PackageManager manager;
//FLAG_ACTIVITY_NEW_TASK
Intent i = new Intent(Intent.ACTION_MAIN);
manager = myContext.getPackageManager();
i = manager.getLaunchIntentForPackage(NomApp);
i.addCategory(Intent.CATEGORY_DEFAULT);
myContext.startActivity(i);


--
Ce n'est pas l'outil le plus important mais la manière de s'en servir


Attention, tu utilises getContexteApplication(), ce qui ne devrait pas fonctionner sur Android 10. Je te conseille de remplacer par getActiviteEnCours().

--
https://github.com/reuniware
https://stackoverflow.com/users/10922639/kotlinisland
Membre enregistré
201 messages
Popularité : +6 (10 votes)
Posté le 24 novembre 2020 - 11:41
merci pour ce conseil ! après test ça marche très bien sur mon smartphone Android 10, tout bon pour moi

--
Ce n'est pas l'outil le plus important mais la manière de s'en servir
Membre enregistré
164 messages
Popularité : +10 (10 votes)
Posté le 24 novembre 2020 - 14:16
D'accord! Moi j'ai dû remplacer beaucoup de getContexteApplication() par getActiviteEnCours()...
Super si tu as résolu ton soucis ! :merci:

--
https://github.com/reuniware
https://stackoverflow.com/users/10922639/kotlinisland
Membre enregistré
201 messages
Popularité : +6 (10 votes)
Posté le 24 novembre 2020 - 15:01
ouai merci en tout cas, suite à ton message j'ai quand même refait un test pour être sûr

--
Ce n'est pas l'outil le plus important mais la manière de s'en servir