PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → Interactions entre 2 applications Android
Interactions entre 2 applications Android
Débuté par popoy, 26 nov. 2014 12:23 - 11 réponses
Posté le 26 novembre 2014 - 12:23
Bonjour a tous,

Comment fait - on pour faire une interaction entre plusieurs applications que l'on développe avec Windev Mobile ?
En effet, il est possible d’envoyer des paramètres a une autre fenêtre windev mobile
Mais comment envoyer des informations vers une autre application WinDev mobile?
ou ouvrir une fenetre d'une autre applications windev mobile

Ainsi On pourrait penser à des modules, add-ons
Exemple : La Fonction CBCapture envoie des données a Zxing qui est une application non windev mobile

à ma connaissance il existe cette application sous Android
SlideIT : https://play.google.com/store/search…
SlideIT propose un clavier ou l'on peut intégrer chacun des dictionnaires , skin
l'utilisateur ne télécharge que ce qu'il souhaite dans un apk a part

J'aimerais donc programmer plusieurs applications Android qui seraient sur le même terminal et communiqueraient entre elles et seraient complementaires.


Merci de m'indiquer une marche a suivre
Fonctions Wlanguage ou Java modifications du manifeste etc
Je prend toutes les pistes
Posté le 28 novembre 2014 - 10:44
pour aider j'ai vu sue des forums android que l'on parle d'intents et d'activity
mais je ne sais pas les utilisés
si quelqu'un a un exemple
Posté le 28 novembre 2014 - 15:29
Bonjour

De mémoire, Adriano Boller a posté un exemple de code pour lancer une
autre appli android dans le forum mobile US

Ca devrait te donner un point de départ

Cordialement


--
Fabrice Harari
Consultant WinDev, WebDev et WinDev Mobile International

NOUVEAU: WXReplication, votre système de réplication open source est
disponible sur mon site web !!!
WXShowroom.com : Montrez vos projets !
Plus d'information sur http://fabriceharari.com


On 11/26/2014 6:23 AM, popoy wrote:
Bonjour a tous,

Comment fait - on pour faire une interaction entre plusieurs
applications que l'on développe avec Windev Mobile ?
En effet, il est possible d’envoyer des paramètres a une autre fenêtre
windev mobile
Mais comment envoyer des informations vers une autre application WinDev
mobile?
ou ouvrir une fenetre d'une autre applications windev mobile

Ainsi On pourrait penser à des modules, add-ons Exemple : La Fonction
CBCapture envoie des données a Zxing qui est une application non windev
mobile

à ma connaissance il existe cette application sous Android
SlideIT : https://play.google.com/store/search…
SlideIT propose un clavier ou l'on peut intégrer chacun des
dictionnaires , skin
l'utilisateur ne télécharge que ce qu'il souhaite dans un apk a part

J'aimerais donc programmer plusieurs applications Android qui seraient
sur le même terminal et communiqueraient entre elles et seraient
complementaires.


Merci de m'indiquer une marche a suivre
Fonctions Wlanguage ou Java modifications du manifeste etc
Je prend toutes les pistes
Posté le 29 novembre 2014 - 00:49
Merci fabrice
je pense que tu parle de http://forum.pcsoft.fr/fr-FR/pcsoft.us.windevmobile/610-execrun-funcional-perfeito-611/read.awp
personellement j'avais trouver http://forum.pcsoft.fr/fr-FR/pcsoft.fr.windevmobile/10663-wm17-android-ouvrir-application-tierce/read.awp

Or je ne cherche pas juste a ouvrir un autre apk mais ouvrir en transmettant des parametres
une sorte de LanceAppliAssociée en précisant l'application

ou ouvrir une fenêtre non principale de mon autre application
ou faire un socket entre 2 appli android sur le même terminal
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 04 décembre 2014 - 23:34
//ExecRun - Funcional - Perfeito

import android.app.Activity;
import android.content.Intent;
import java.lang.*;
import android.util.*;
import java.lang.Exception;
import android.util.Log;

PUBLIC static booleanExecRun(stringAplicativo){
try{

IF(Aplicativo==null){
RETURNFalse;
}
ELSE{
Intent Apk=getActiviteEnCours().getPackageManager().getLaunchIntentForPackage(Aplicativo);
getActiviteEnCours().startActivity(Apk);
RETURNTrue;
}

}
catch(EXCEPTIONe) {
Log.e("WM",e.toString());
RETURNFalse;
}
}
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 04 décembre 2014 - 23:35
ExecRun("br.com.taxi62")
Posté le 05 décembre 2014 - 09:44
Adriano,
A tu réussi a faire un -broadcastreceiver qui fonctionne sous windev mobile?

http://forum.pcsoft.fr/fr-FR/pcsoft.us.windevmobile/709-broadcastreceiver-this-function-need-help-complete-was-unable/read.awp

et

http://27130.foren.mysnip.de/read.php…

Personnellement Je vais lire les liens que tu m'as gentiment fourni
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 12 décembre 2014 - 20:47
Je vais analyser et essayer de nouveau faire, je avais besoin d'un coup de quelqu'un et expert en java-delà de ce que je sais être capable de faire. Je vais analyser votre lien et vois avec votre exemple que je peux faire dans WINDEV Mobile. Si vous avez quelqu'un qui travaille avec java peut se réunir pour faire un exemple de travail et dépôt de PCSoft aux autres utilisateurs. Je compte sur votre aide.

http://27130.foren.mysnip.de/read.php…

Hi ALL,

I am trying to Use the Android Alarmmanager to set an Intent to check AND IF not running start my Windev Mobile application again so that it keeps running even WHEN closed by user OR Android system. Only WHEN they logoff the application is actualy closed.

I have created the following Java code:

PUBLIC static void JKeepAliveAlarm()
{
try {
AlarmManager alarm;
Calendar cal;
PendingIntent alarmIntent;

// Retrieve the current activity
Activity tmpActivity = getCurrentActivity();

// Retrieve the current Context
Context tmpContext = getApplicationContext();

cal = Calendar.getInstance();
alarm = (AlarmManager)tmpContext.getSystemService(tmpContext.ALARM_SERVICE);
Intent myIntent = new Intent(tmpContext,AlarmReceiver.class);
alarmIntent = PendingIntent.getBroadcast(tmpContext, 0, myIntent, 0);

// Start every 30 seconds
alarm.setInexactRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 30*1000, alarmIntent);

Toast.makeText(tmpContext, "Keep Alive Alarm SET", Toast.LENGTH_LONG).show();
}
catch(EXCEPTION e) {
e.printStackTrace();
}
}


I call this from the project code at startup. The toast is displayed so alarm is running.

The Receiverclass is defined as:

PUBLIC class AlarmReceiver extends BroadcastReceiver {

@Override
PUBLIC void onReceive(Context context, Intent intent) {

try {
Toast.makeText(context, "Alarm - Start", Toast.LENGTH_LONG).show();

// Try to start the app if not allready running
// TODO

Toast.makeText(context, "Alarm - End", Toast.LENGTH_LONG).show();
}
catch(EXCEPTION e) {
e.printStackTrace();
}
}
}


IF the alarm would trigger I would see the toast on the screen. But nothing is executed, the receiver is not called ??!

I also added the Receiver to the Manifest:

ManifestPart.png


I checked via the adb shell dumpsys alarm > dump.txt the status of the alarms AND the alarm is created AND is firing its Event.

RTC_WAKEUP #0: Alarm{43854bb0 type 0 com.xxxx.yyyy}

type=0 WHEN=+5s605ms repeatInterval=30000 Count=1

operation=PendingIntent{432cadd0: PendingIntentRecord{430215c0 com.xxx.yyyy broadcastIntent}}

+1m38s35ms running, 101 wakeups, 101 alarms: com.xxx.yyyy

cmp={com.xxxx.yyyy/com.xxxx.yyyy.AlarmReceiver}

But my receiver is never called ? :confused:

I tried different names IN the Manifest, but nothing seems to work.

I also Use the alarmManager for updating the application by running an APK File after the program is closed, AND this works fine.

I checked several Android sources on the INTERNET AND the basic configuration is IN place. Being:

Create a class AlarmReceiver
Create a PendingIntent AND setup this via the Alarmmanager
Change the Manifest to define the receiver


Does anybody has a working broadcast receiver IN Windev Mobile 19 AND can tell me what I am doing wrong ? Maybe there is something missing ?

Hope you can help me !
Thanks
Danny



Edited 1 time(s). Last edit at 11/19/2014 03:05PM by Danny Lauwers.

Options: ReplyQuote
Re: [WM19] Android Alarmmanager AND BroadcastReceiver DO not work ? [SOLVED] #
Posted by: Danny Lauwers
Date: December 10, 2014 03:26PM

Hi,

I got the anwser to my own question; after some hours of reseach AND testing. :)

Ive by chance found how to work with Broadcast receivers. The clue is to Use the correct name IN the Definition of the receiver IN the manifest.

WHEN having this class

PUBLIC static class AlarmReceiver extends BroadcastReceiver {

@Override
PUBLIC void onReceive(Context context, Intent intent) {

try {
// Retrieve the current Context
Context tmpContext = getApplicationContext();

Toast.makeText(tmpContext, "test - Start", Toast.LENGTH_LONG).show();

// Stuff todo

Toast.makeText(context, "Awake CareApp - End", Toast.LENGTH_LONG).show();
}
catch(EXCEPTION e) {
e.printStackTrace();
}
}
}



AND the alarm is triggerd by this

PUBLIC static void JKeepAliveAlarm()
{
try {
AlarmManager alarm;
Calendar cal;
PendingIntent alarmIntent;

// Retrieve the current activity
Activity tmpActivity = getCurrentActivity();

// Retrieve the current Context
Context tmpContext = getApplicationContext();

cal = Calendar.getInstance();
alarm = (AlarmManager)tmpContext.getSystemService(tmpContext.ALARM_SERVICE);
Intent myIntent = new Intent(tmpContext,AlarmReceiver.class);
alarmIntent = PendingIntent.getBroadcast(tmpContext, 0, myIntent, 0);

// Start every 30 seconds
alarm.setInexactRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 30*1000, alarmIntent);

Toast.makeText(tmpContext, "Keep Alive Alarm SET", Toast.LENGTH_LONG).show();
}
catch(EXCEPTION e) {
e.printStackTrace();
}
}



The alarm is triggered every 30 seconds AND firing the alarm intent.

WHEN defining this IN the manifest under the application node

manifest2.png


Will Link the alarm correctly to the code to Execute.

The problem was that the name must be correct, you have to look inside the android folder WHERE the code is generated AND look inside the wdgen folder. AND look for your class that Contains the AlarmReciever.class code.
This wdgen folder is a deep subfolder of the "Android\Generation" folder under you project folder.

THEN you have to build the .wdgen.GWDCPCOL_Java$AlarmReceiver string to match the correct location of your class AND Use this as the android:name of you receiver node.

!! This is not a Java thing, but a PCSoft Windev Mobile Android thing. Because Windev Mobile compiles the android application IN a special way, you need to Now the naming convention of PC-Soft IN order to set your manifest correctly. I did not found any of this Info IN the help OR on a forum, AND this is crucial to Get some native android functionality working within your WinDev Mobile Android application.

I have reported this to PC-Soft with the request to include this IN the online help.

Once you have the name correct, the broadcast receiver is working. This opens up a lot of Android Native functionality because alot of things are working with broadcastreceivers.

Hope this may help some of you to natively extend there Windev Mobile Android application.
IF you DO find some interesting Native code that is working with WinDev Mobile Android applications todo some cool stuff, please DO share this on the forum as well !

Have a nice day
Danny



Edited 2 time(s). Last edit at 12/10/2014 03:26PM by Danny Lauwers.

Options: ReplyQuote
Re: [WM19] Android Alarmmanager AND BroadcastReceiver DO not work ? [SOLVED] #
Posted by: Popoy
Date: December 12, 2014 12:27AM

How DO you Create The class Java AlarmReceiver IN Windev Mobile ?

Options: ReplyQuote
Re: [WM19] Android Alarmmanager AND BroadcastReceiver DO not work ? [SOLVED] #
Posted by: Danny Lauwers
Date: December 12, 2014 09:27AM

Hi,

You make GLOBAL procedures AND create a FUNCTION IN it. I Call it "InitClasses", you make this a Java FUNCTION not a W Language FUNCTION. (This is IN the front of the FUNCTION header WHERE you see WL OR Java, you can click on this to change it.

See: http://doc.pcsoft.fr/en-US/?9000011&name=Entering_Java_code for more info

THEN you make this FUNCTION completely empty. THEN start IN the top with writing the needed import statements:

for example:

import java.io.IOException;
import java.io.InputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;


Depending on what android Java functionality you need you need to Add the correct imports ELSE you will Get a Java compiler Error WHEN you create the APK File.

THEN you can create classes below the import lines

PUBLIC static class AlarmReceiver extends BroadcastReceiver {

@Override
PUBLIC void onReceive(Context context, Intent intent) {

try {
// Retrieve the current Context
Context tmpContext = getApplicationContext();

//// Do your stuff here
}
catch(EXCEPTION e) {
e.printStackTrace();
}
}
}


Depending on the need it has to be static OR not. It depends on what class your making etc... Static classes can be used directly without a need for an instance. Other classes need an instance first before you can use them. You have to call some Java code todo this.

IF your application is still alive, you could call via CallWLProcedure a WLanguage FUNCTION todo some stuff. But remember that the alarmReciever will also be run (depending on how you set the alarm) WHEN your application is not running OR is destroyed by the system. IN that CASE calling a FUNCTION from your program does not work. So you have to take care of exceptions AND null pointers.

Hope this helps IN creating the class.

Danny

Options: ReplyQuote
Re: [WM19] Android Alarmmanager AND BroadcastReceiver DO not work ? [SOLVED] #
Posted by: popoy
Date: December 12, 2014 11:20AM

Hi,

I Insert the imports

import android.content.Context;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.widget.Toast;
import java.util.Calendar;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;


But I have
Warning: Parentheses not found
with line

PUBLIC static class AlarmReceiver extends BroadcastReceiver {

Options: ReplyQuote
Re: [WM19] Android Alarmmanager AND BroadcastReceiver DO not work ? [SOLVED] #
Posted by: Danny Lauwers
Date: December 12, 2014 04:00PM

popoy,

This is "normal". Just ignore the warnings IF No Error occurs at Compile time.

I have reported this behavior to PC-Soft

Danny
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 12 décembre 2014 - 20:48
Toujours pas de solution ou exemple in Windev Mobile

;(
Posté le 13 décembre 2014 - 00:26
J'ai du mal comprendre (mon anglais n'est pas très bon).
Il me semble que Danny a réussi

Il a modifié le manifeste avec le nom de la collection de procédure globale
Il a trouvé le bon nom dans le répertoire:
c:\Mes Projets Mobile\Android Alarmmanager\Android\Generation\src\com\masociete\android_alarmmanager\wdgen\
Dans son exemple .wdgen.GWDCPCOL_Java$AlarmReceiver

Ai je Vrai ou Faux ?8)


Pour ceux qui se demande comment récupérer

Il existe une méthode de contournement pour copier le répertoire Android en prenant tout ton temps.

Explication :
Lors de la génération d’une application Android
On va Créer une Erreur que l’on va corriger par la suite pour nous donner accès au Source généré par WinDev Mobile
Pour Cela On ajoute un fichier peu importe sa taille et son type

Dans Destination APK (intégration de fichiers) il est possible de personnalisé la destination comme par exemple
drawable-hdpi si on souhaite mettre une image dans ‘res/drawable-hdpi’.
(plus de détail : http://doc.pcsoft.fr/fr-FR/?9000109)

Au lieu de cet exemple on demande de le mettre dans values-iw.
Cela va provoquer une Erreur de Compilation Java.

Pendant que cet Erreur Apparaît (ne pas quitter l'erreur) il suffit de copier le répertoire Android vers un autre endroit
Pour l'analyser
Posté le 07 juin 2020 - 12:26
For more in android http://www.androidcoding.in