简体   繁体   中英

Android command line popup message

I know how to create and run command line console programs in android. For example a simple one would be for file Hellos.java:

public class Hellos {
    public static void main(String[] args) {
    System.out.print("Hello World");
    }
}

then $ javac Hellos.java, then something like $ dx --dex --output=Hellos.jar Hellos.class and after in android term emulator (still DVM): $ dalvikvm -cp Hellos.jar Hellos

Now I know very well that awt and swing are not part of DVM or Android Runtime. so replacing Hellos.java with Hellow.java:

import javax.swing.*;        

public class Hellow {
    private static void createAndShowGUI() {
        JFrame frame = new JFrame("HelloWorldSwing");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JLabel label = new JLabel("Hello World");
        frame.getContentPane().add(label);
        frame.pack();
       frame.setVisible(true);
    }

    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}

can run very well in command line on x86 OS supporting JVM but can't run on Android for the reasons explained above (no need to go again through why it won't). My question however, is there something equivalent in writing and producing a program than can be run from the command line in android with the same simplicity as that of Hellos and yet can popup a text message? The operative words here are simplicity and command line. I know that you can create an project with many folders and structures to make an apk. That is not what I want. I am asking for the other option if it exists.

is there something equivalent in writing and producing a program than can be run from the command line in android with the same simplicity as that of Hellos and yet can popup a text message?

No.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM