How can I pass String value from EditText In Android Activity to Python Script and also make the activity able to retrieve the String result from a function in the python script such as displaying the retrieved String in TextView ?
And my python script is not in "sl4a" format but it is ordinary script
and it is also complex as it needs importing another scripts inside it which one of them connects to sqlite database .
I want to put the script in assets folder in Android or in res/raw folder
and I don't want the android application to need internet , I want all things embedded in the app .
simple example for this matter is
script.py
def addTwoNbrs(x,y):
return x+y
and in android activity
Button btn = (Button)findViewById(R.id.button1);
final EditText et1 = (EditText)findViewById(R.id.editText1);
final EditText et2 = (EditText)findViewById(R.id.editText2);
final TextView result = (TextView)findViewById(R.id.textView1);
btn.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
int x = new Integer(et1.getText().toString());
int y = new Integer(et2.getText().toString());
// How to call python script with these 2 parameters x , y to calculate
// return the result from the script
}
});