FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV Mobile 2024
→
Getting the correct context to use for AppCompatActivity in an external library
Getting the correct context to use for AppCompatActivity in an external library
Débuté par Thysie, 13 jan. 2020 15:05 - Aucune réponse
Connectez-vous…
Thysie
#1
Membre enregistré
6 messages
Posté le 13 janvier 2020 - 15:05
Hello
I am using an external library that takes AppCompatActivity (derived from androidx.appcompat.app.AppCompatActivity) as a parameter.
Neither getApplicationContext or getCurrentActivity seems to be able to provide me the correct context.
When trying to cast the context that gets passed to my library (on both above) to AppCompactActivity within the library, I get an exception stating "Failed resolution of: Landroidx/appcompat/app/AppCompactActivity;"
Java procedure in Windev:
imports ...
public static String init(){
//Context context = getApplicationContext();
Activity activity = getCurrentActivity();
Main main = new Main(activity);
String response = main.run();
return response;
}
and in the library:
public Main(Activity activity) {
if (activity != null){
AppCompatActivity altContext = (AppCompatActivity) activity; //error thrown here
factory = new TransactionFactory(activity, true, ServiceConfigurationEnum.UAT);
}
else{
return;
}
}
Any suggestions on working around this or getting the context in the correct format to be passed/cast to be usable?
Kind Regards
MJ
P.S.
If someone could tell me why Windev lacks support for androidx libraries that would be great, i.e "import androidx.appcompat.app.AppCompatActivity;"
--
Regards,
Thysie
Signaler
0
0
→ Revenir à WINDEV Mobile 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (précédentes versions)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte