0

Is it possible in AndroidStudio to use a string as code? For example if I load a file called code.txt including Log.d("DEBUG", yourstring); and it will be included at the Java file

public onClick(View v){
    String string = "It worked";
    codetxt.include();
}

And if it is clicked it will Log It worked If this is possible please tell me!

Marcin Wroblewski
  • 3,491
  • 18
  • 27
Strukteon
  • 13
  • 1
  • 7
  • It may very well be possible somehow, but not in any default way. Would be a huge security problem. – Sami Kuhmonen Feb 15 '17 at 12:29
  • 2
    See this answear here [Dynamic Code Execution](http://stackoverflow.com/questions/4166135/dynamic-code-execution) – Edu G Feb 15 '17 at 12:31

1 Answers1

1

Yes, you can it with reflection. But it's not simple. I used other JVM languages like clojure or Jython for similar tasks.

Michael Kazarian
  • 4,376
  • 1
  • 21
  • 25