Afficher heure en XML

Afficher heure en XML - Android - Programmation

Marsh Posté le 04-02-2021 à 19:12:36    

Bonjour,
 
Je voudrais afficher l'heure dans une appli Android mais je n'ai accès uniquement aux fichiers XML est il possible de la faire afficher dans ce fichier par exemple ?
 
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:layout_width="fill_parent" android:layout_height="@dimen/compactEtaBarHeight"
  xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
    <RelativeLayout android:id="@id/fullLayout" android:visibility="visible" android:layout_width="fill_parent" android:layout_height="fill_parent" android:animateLayoutChanges="true" android:layoutDirection="ltr">
        <com.waze.sharedui.views.WazeTextView android:textStyle="bold" android:gravity="center" android:id="@id/lblArrivalTime" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_centerVertical="true" style="@style/compactEtaBarText" />
        <ImageView android:id="@id/imgEtaDetailsSeparatorLeft" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10.0dip" android:layout_marginRight="10.0dip" android:src="@drawable/eta_compact_bar_separator_dot" android:layout_toLeftOf="@id/lblArrivalTime" android:layout_centerVertical="true" />
        <ImageView android:id="@id/imgEtaDetailsSeparatorRight" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10.0dip" android:layout_marginRight="10.0dip" android:src="@drawable/eta_compact_bar_separator_dot" android:layout_toRightOf="@id/lblArrivalTime" android:layout_centerVertical="true" />
        <com.waze.sharedui.views.WazeTextView android:id="@id/lblTimeToDestination" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toLeftOf="@id/imgEtaDetailsSeparatorLeft" android:layout_centerVertical="true" style="@style/compactEtaBarText" />
        <com.waze.sharedui.views.WazeTextView android:id="@id/lblDistanceToDestination" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/imgEtaDetailsSeparatorRight" android:layout_centerVertical="true" style="@style/compactEtaBarText" />
    </RelativeLayout>
    <com.waze.sharedui.views.WazeTextView android:textStyle="bold" android:gravity="center" android:layout_gravity="center" android:id="@id/lblOfflineDistanceToDestination" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/compactEtaBarText" />
</FrameLayout>  

Reply

Marsh Posté le 04-02-2021 à 19:12:36   

Reply

Marsh Posté le 04-02-2021 à 22:56:51    

As-tu des notions de programmation ?

Reply

Marsh Posté le 05-02-2021 à 13:32:10    

Oui un peu bien que je ne connaisse pas ce langage .
En fait j'ai "dezipé" une .apk d'où je peux agir sur les fichiers XML puis recompiler et réinstaller l'application.
Est il donc possible en intercalant dans un fichier XML autre chose que prévu pour de lui faire afficher l'heure par exemple.  

Reply

Marsh Posté le 06-02-2021 à 18:02:38    

Essaie de rajouter une simple TextView avec un texte fixe pour voir ce que ça donne :)

Reply

Marsh Posté le 07-02-2021 à 17:32:54    

ok j'ai compris c'est impossible !!!.
 
Du coup je vais essayer de faire ma propre apk mais si tu veux bien Tamiya je crois que j'aurais besoin de ton aide.

Reply

Marsh Posté le 14-02-2021 à 15:16:40    

ok j'ai suivi les cours java et android tout n'est pas claire mais j'avance un peu.
 
Voici ce que je veux faire, l'algorithme:
 
1) Vérifier si waze est ouvert:
       -oui regarder s'il est au 1er plan sinon le mettre.
       -non démarrer waze.
 
2) vérifier si waze est au 1er plan :
     -oui afficher heure en bas.
     -non afficher heure en haut.
 
3) répéter 2 après une pause de 5 secondes.
 
C'est pas un prog qui à l'air compliqué mais je coince sur le début pour démarrer waze.
 
voici mon code:
package com.lunch.lanceurwaze;
 
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
 
public class MainActivity extends AppCompatActivity {
    private TextView text = null;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        Intent i = getPackageManager().getLaunchIntentForPackage("com.waze" );
        if (i != null)
        {
            startActivity(i);
        }
 
    }
}
 
Et... pas d'erreur mais waze ne se lance pas... Une idée ?

Reply

Marsh Posté le 14-02-2021 à 19:09:18    

j'ai aussi testé ca sans plus de succès:
 
        Intent intent = new Intent (Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setComponent(new ComponentName("com.waze" ));

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed