Android QPython3 調(diào)用 其他 Android App
需要android.py??https://www.bilibili.com/read/cv8679914
可視化還需要:
BaseWindow.py??https://www.bilibili.com/read/cv8680125
MultText.py??http://www.bilibili.com/read/cv7643432
MltiText.py??http://www.bilibili.com/read/cv8144252
Output.py??http://www.bilibili.com/read/cv7830277

【QPythonSupport/app/src/main/AndroidManifest.xml】
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
? ? package="czc.qpython.support" >
? ? <application
? ? ? ? android:allowBackup="true"
? ? ? ? android:icon="@drawable/ic_launcher"
? ? ? ? android:label="@string/app_name"
? ? ? ? android:theme="@style/AppTheme"
android:resizeableActivity="true">
? ? ? ? <activity
? ? ? ? ? ? android:name=".MainActivity"
? ? ? ? ? ? android:label="@string/app_name" >
? ? ? ? ? ? <intent-filter>
? ? ? ? ? ? ? ? <action android:name="android.intent.action.MAIN" />
? ? ? ? ? ? ? ? <category android:name="android.intent.category.LAUNCHER" />
? ? ? ? ? ? </intent-filter>
? ? ? ? </activity>
? ? </application>
</manifest>

【QPythonSupport/app/src/main/res/layout/activity_main.xml】
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent"
? ? android:gravity="center"
android:orientation="vertical">
<TextView
? ? ? ? android:text="Name"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content" />
? ? <EditText
android:id="@+id/etName"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content" />
<TextView
? ? ? ? android:text="Data"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content" />
<EditText
android:id="@+id/etData"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content" />
</LinearLayout>

【QPythonSupport/app/src/main/java/czc/qpython/support/MainActivity.java】
package czc.qpython.support;
import android.app.*;
import android.os.*;
import android.content.*;
import android.widget.*;
public class MainActivity extends Activity?
{
? ? @Override
? ? protected void onCreate(Bundle savedInstanceState)
? ? {
? ? ? ? super.onCreate(savedInstanceState);
? ? ? ? setContentView(R.layout.activity_main);
Intent intent=getIntent();
String stName=intent.getStringExtra("name");
String stData=intent.getStringExtra("data");
EditText etName=(EditText) findViewById(R.id.etName);
EditText etData=(EditText) findViewById(R.id.etData);
etName.setText(stName);
etData.setText(stData);
Intent intentR=new Intent();
intentR.putExtra("result",etData.getText());
intentR.putExtra("error","null");
MainActivity.this.setResult(RESULT_OK,intentR);
? ? }
}


【QPythonSupport/QPythonMain.py】命令行
from android import *
e={'name':'Hello','data':'World'}
f=esla('startActivityForResult','','','',e,
? 'czc.qpython.support',
? 'czc.qpython.support.MainActivity')
print(r)

【QPythonSupport/QPythonMain.py】部分可視化
from android import *
from BaseWindow import *
from MultText import *
from MltiText import *
m=MltiText('請輸入:',('name','data'))
e={'name':m[0],'data':m[1]}
f=esla('startActivityForResult','','','',e,
? 'czc.qpython.support',
? 'czc.qpython.support.MainActivity')
r=f['extras']
r=MultText('結(jié)果',
('result',r['result'],
'error',r['error']))
print(r)

【QPythonSupport/QPythonMain.py】全部可視化
from android import *
from BaseWindow import *
from MultText import *
from MltiText import *
from Output import *
m=MltiText('請輸入:',('name','data'))
e={'name':m[0],'data':m[1]}
f=esla('startActivityForResult','','','',e,
? 'czc.qpython.support',
? 'czc.qpython.support.MainActivity')
r=f['extras']
r=MultText('結(jié)果',
('result',r['result'],
'error',r['error']))
Output('\n'.join(r))


視頻:
https://www.bilibili.com/video/BV1VK4y1L7Q1
QPython函數(shù):
startActivity(self, action, uri=None, type=None, extras=None, wait=None, packagename=None, classname=None)
startActivityForResult(self, action, uri=None, type=None, extras=None, packagename=None, classname=None)
作者:乘著船@Bilibili
更多文章+下載鏈接:https://www.bilibili.com/read/readlist/rl321663