• 大小: 7.5MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-17
  • 语言: Java
  • 标签: python  android  

资源简介

android的python控制台的例子

资源截图

代码片段和文件信息

package com.example.upython;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import android.os.Bundle;
import android.app.Activity;
import android.os.Handler;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.srplab.www.starcore.*;

public class MainActivity extends Activity {

private void copyFile(Activity c String NameString desPath) throws IOException {  
File outfile = null;
if( desPath != null )
outfile = new File(“/data/data/“+getPackageName()+“/files/“+desPath+Name);
else
outfile = new File(“/data/data/“+getPackageName()+“/files/“+Name); 
    if (!outfile.exists()) {
     outfile.createNewFile();
         FileOutputStream out = new FileOutputStream(outfile);        
        byte[] buffer = new byte[1024];  
        InputStream in;  
        int readLen = 0;  
        if( desPath != null )
         in = c.getAssets().open(desPath+Name);
        else
         in = c.getAssets().open(Name);
            while((readLen = in.read(buffer)) != -1){  
                out.write(buffer 0 readLen);  
            }  
            out.flush();  
            in.close();  
        out.close();  
    }  


StarCoreFactory starcore;
StarServiceClass Service;
StarSrvGroupClass SrvGroup;

EditText editbox;
TextView textbox;
Button   compilebtn;
Button   runbtn;
Button   clearbtn;

Handler UIHandler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        File destDir = new File(“/data/data/“+getPackageName()+“/files“);
        if(!destDir.exists())
            destDir.mkdirs();
        java.io.File python2_7_libFile = new java.io.File(“/data/data/“+getPackageName()+“/files/python2.7.zip“);
        if( !python2_7_libFile.exists() ){
            try{
                copyFile(this“python2.7.zip“null);
            }
            catch(Exception e){
            }
        }
        
        /*----init starcore----*/
        StarCoreFactoryPath.StarCoreCoreLibraryPath = this.getApplicationInfo().nativeLibraryDir;
        StarCoreFactoryPath.StarCoreShareLibraryPath = this.getApplicationInfo().nativeLibraryDir;
        StarCoreFactoryPath.StarCoreOperationPath = “/data/data/“+getPackageName()+“/files“;
        
        final String LibPath = this.getApplicationInfo().nativeLibraryDir;
        final String PackagePath = “/data/data/“+getPackageName();
        
        new Thread(new Runnable(){
            @Override
            public void run() {
        starcore= StarCoreFactory.GetFactory();
        Service=starcore._InitSimple(“test““123“00);
starcore._RegMsgCallBack_P(new StarMsgCallBackInterface(){
public object Invoke(int ServiceGroupID int uMes object wParam object lParam){
if (uMes == starcore._Getint(“MSG_

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-03-06 21:16  upython.android\
     目录           0  2017-03-06 21:16  upython.android\.gradle\
     目录           0  2017-03-06 21:33  upython.android\.gradle\2.14.1\
     目录           0  2017-03-06 21:16  upython.android\.gradle\2.14.1\taskArtifacts\
     文件          31  2017-03-06 21:16  upython.android\.gradle\2.14.1\taskArtifacts\cache.properties
     文件          17  2017-03-06 22:02  upython.android\.gradle\2.14.1\taskArtifacts\cache.properties.lock
     文件       28726  2017-03-06 22:02  upython.android\.gradle\2.14.1\taskArtifacts\fileHashes.bin
     文件      339421  2017-03-06 22:02  upython.android\.gradle\2.14.1\taskArtifacts\fileSnapshots.bin
     文件       27170  2017-03-06 22:02  upython.android\.gradle\2.14.1\taskArtifacts\fileSnapshotsToTreeSnapshotsIndex.bin
     文件      110120  2017-03-06 22:02  upython.android\.gradle\2.14.1\taskArtifacts\taskArtifacts.bin
     目录           0  2017-03-06 21:33  upython.android\.gradle\2.14.1\tasks\
     目录           0  2017-03-06 21:33  upython.android\.gradle\2.14.1\tasks\_app_compileDebugJavaWithJavac\
     目录           0  2017-03-06 21:33  upython.android\.gradle\2.14.1\tasks\_app_compileDebugJavaWithJavac\localClassSetAnalysis\
     文件       25324  2017-03-06 22:02  upython.android\.gradle\2.14.1\tasks\_app_compileDebugJavaWithJavac\localClassSetAnalysis\localClassSetAnalysis.bin
     文件          17  2017-03-06 22:02  upython.android\.gradle\2.14.1\tasks\_app_compileDebugJavaWithJavac\localClassSetAnalysis\localClassSetAnalysis.lock
     目录           0  2017-03-06 21:33  upython.android\.gradle\2.14.1\tasks\_app_compileDebugJavaWithJavac\localJarClasspathSnapshot\
     文件       18784  2017-03-06 22:02  upython.android\.gradle\2.14.1\tasks\_app_compileDebugJavaWithJavac\localJarClasspathSnapshot\localJarClasspathSnapshot.bin
     文件          17  2017-03-06 22:02  upython.android\.gradle\2.14.1\tasks\_app_compileDebugJavaWithJavac\localJarClasspathSnapshot\localJarClasspathSnapshot.lock
     目录           0  2017-03-06 22:03  upython.android\.idea\
     文件           7  2017-03-06 21:14  upython.android\.idea\.name
     文件         686  2017-03-06 21:14  upython.android\.idea\compiler.xml
     目录           0  2017-03-06 21:14  upython.android\.idea\copyright\
     文件          76  2017-03-06 21:14  upython.android\.idea\copyright\profiles_settings.xml
     文件         159  2017-03-06 21:14  upython.android\.idea\encodings.xml
     文件         835  2017-03-06 21:15  upython.android\.idea\gradle.xml
     目录           0  2017-03-06 21:16  upython.android\.idea\libraries\
     文件         264  2017-03-06 21:16  upython.android\.idea\libraries\android_android_19.xml
     文件         247  2017-03-06 21:16  upython.android\.idea\libraries\starcore_android_r2_51.xml
     文件         496  2017-03-06 21:16  upython.android\.idea\libraries\support_v4_19_1_0.xml
     文件        2644  2017-03-06 22:03  upython.android\.idea\misc.xml
     文件         367  2017-03-06 21:15  upython.android\.idea\modules.xml
............此处省略61个文件信息

评论

共有 条评论