To start with - Yes, I know that this is crazy/strange. But I need it :).
I want to find simpliest way to run single java file (and prefer non-terminal answers :) - if they are possible ) in Android Studio. I mean random .java file from my Android project in which I'll write main(..) method. And there's one more thing: I don't want to create any new modules (I've already seen answers about adding Java library module). I just want to click something and run my (single) file, the same way as I can do it in Eclipse. Is it possible?
Android Studio will automatically give an option "Run YourClass. mainActivity()", when you right-click anywhere in the editor's editing space. Just right click in the Java file and there will be an option to run that particular Java class.
Actually, the main() method is the Android framework class android. app. ActivityThread . This method creates the Main (UI) Thread for an OS process, sets up the Looper on it and starts the event loop.
One thing that might be confusing you, like it was confusing me:
If there is the standard method to start Java application
public static void main (String[] args ) {
// your block here
}
Android Studio will automatically give an option "Run YourClass.mainActivity()", when you right-click anywhere in the editor's editing space.
Just right click in the Java file and there will be an option to run that particular Java class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With