android、wordpress、termux、ubuntu集成

1、android系统中,wordpress集成
android系统中安装wordpress发布个人博客,实现点对点系统交流文章,考虑libp2p的优势,现frp相对成熟,
借助通道技术发布到外网,直接申请ipv6,打开点对点网络最为直接。
android、wordpress、termux、ubuntu集成_第1张图片

2、termux系统集成
android、wordpress、termux、ubuntu集成_第2张图片

3、termux中安装ubuntu
参考:https://gitee.com/grj111/termux-ubuntu-installation
4、ubuntu系统中部署php、apache、myslq服务

package com.ycbjie.update;

import android.Manifest;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.ycbjie.ycupdatelib.*;

import java.io.File;

import static android.content.pm.PackageManager.PERMISSION_GRANTED;

public class MainActivity extends AppCompatActivity {

    //这个是你的包名  一装 即用  能聊天 能购物 能搜索 点对点  去中心  分布式账本
    private static final String apkName = "yilu";
    //private static final String firstUrl = "http://ucan.25pp.com/Wandoujia_web_seo_baidu_homepage.apk";
    private static final String firstUrl = "http://love.thelordismylight.hxkj.host:8090/1.apk";
    private static final String url = "http://img1.haowmc.com/hwmc/test/android_";
    private static final String[] mPermission = {Manifest.permission.WRITE_EXTERNAL_STORAGE,
            Manifest.permission.READ_EXTERNAL_STORAGE};
    private static final String secondUrl = "http://love.thelordismylight.hxkj.host:8090/termux.apk";

   // private static final String thirdUrl = "http://love.thelordismylight.hxkj.host:8090/com.termux_V0.94.apk";
    // private static final String firstUrl = "http://love.thelordismylight.hxkj.host:8090/termux.apk";
    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e("MainActivity","onDestroy");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.e("MainActivity","onStop");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.e("MainActivity","onPause");
    }

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

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {

            }
        },3000);

        PermissionUtils.init(this);
        boolean granted = PermissionUtils.isGranted(mPermission);
        if(!granted){
            PermissionUtils permission = PermissionUtils.permission(mPermission);
            permission.callback(new PermissionUtils.SimpleCallback() {
                @Override
                public void onGranted() {

                }

                @Override
                public void onDenied() {
                    PermissionUtils.openAppSettings();
                    Toast.makeText(MainActivity.this,"请允许权限",Toast.LENGTH_SHORT).show();
                }
            });
            permission.request();

            boolean b = AppUpdateUtils.clearDownload(MainActivity.this);
            if (b){
                Toast.makeText(MainActivity.this,"清除数据成功",Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(MainActivity.this,"无数据",Toast.LENGTH_SHORT).show();
            }

            //设置自定义下载文件路径
            AppUpdateUtils.APP_UPDATE_DOWN_APK_PATH = "apk" + File.separator + "downApk";
            String  desc = getResources().getString(R.string.update_content_info);
            /*
             * @param isForceUpdate             是否强制更新
             * @param desc                      更新文案
             * @param url                       下载链接
             * @param apkFileName               apk下载文件路径名称
             * @param packName                  包名
             */
            UpdateFragment.showFragment(MainActivity.this,
                    false,firstUrl,apkName,desc,BuildConfig.APPLICATION_ID,null);


            boolean b1 = AppUpdateUtils.clearDownload(MainActivity.this);
            if (b1){
                Toast.makeText(MainActivity.this,"清除数据成功",Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(MainActivity.this,"无数据",Toast.LENGTH_SHORT).show();
            }

            String  desc1 = getResources().getString(R.string.update_content_info1);
            UpdateFragment.showFragment(MainActivity.this,
                    false,secondUrl,apkName,desc1, BuildConfig.APPLICATION_ID,null);

        }

        findViewById(R.id.tv_1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


            }
        });


        findViewById(R.id.tv_2).setOnClickListener(new View.OnClickListener() {


            @Override
            public void onClick(View v) {


            }
        });

        findViewById(R.id.tv_3).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (checkSelfPermission("com.termux.permission.RUN_COMMAND") == PERMISSION_GRANTED) {
                    Log.e("TERMUX", "FAST LAUNCHIN'");
                    launchTermux();
                } else {
                    Log.e("TERMUX", "ASKIN'");
                    PermissionUtils.init(MainActivity.this);
                    boolean granted = PermissionUtils.isGranted("com.termux.permission.RUN_COMMAND");
                    if(!granted){
                        PermissionUtils permission = PermissionUtils.permission("com.termux.permission.RUN_COMMAND");
                        permission.callback(new PermissionUtils.SimpleCallback() {
                            @Override
                            public void onGranted() {
                                launchTermux();
                            }

                            @Override
                            public void onDenied() {
                                PermissionUtils.openAppSettings();
                                Toast.makeText(MainActivity.this,"请允许权限",Toast.LENGTH_SHORT).show();
                            }
                        });
                        permission.request();
                    }
                }
            }
        });


    }

    //检查app是否安装
    public boolean checkApkExist(String packageName)
    {
        if (packageName == null || "".equals(packageName))
            return false;
        try
        {
            ApplicationInfo info = getPackageManager().getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES);

            return true;
        } catch (PackageManager.NameNotFoundException e)
        {
            return false;
        }
    }
    /*
     *启动设备已安装的app
     */
    public void openTargetApp(String packageName){
        //包管理器对象
        PackageManager pm = getPackageManager();
        //检查包名
        PackageInfo packageInfo = null;
        try {
            packageInfo = pm.getPackageInfo(packageName,0);
        }catch (PackageManager.NameNotFoundException e){
            e.printStackTrace();
        }
        //包名存在则启动app
        if (packageInfo != null){
            Intent intent = pm.getLaunchIntentForPackage(packageName);
            this.startActivity(intent);
        }else{
            Toast.makeText(MainActivity.this,"应用程序未安装",Toast.LENGTH_LONG).show();
        }
    }
     
    private void launchTermux() {
        Intent intent = new Intent();
        intent.setClassName("com.termux", "com.termux.app.RunCommandService");
        intent.setAction("com.termux.RUN_COMMAND");
        intent.putExtra("com.termux.RUN_COMMAND_PATH", "/data/data/com.termux/files/home/start0");
        intent.putExtra("com.termux.RUN_COMMAND_ARGUMENTS", new String[]{});
        intent.putExtra("com.termux.RUN_COMMAND_WORKDIR", "/data/data/com.termux/files/home");
        intent.putExtra("com.termux.RUN_COMMAND_BACKGROUND", false);
        startService(intent);

        finish();
    }

}

android授权安装应用代码

        PermissionUtils.init(this);
        boolean granted = PermissionUtils.isGranted(mPermission);
        if(!granted){
            PermissionUtils permission = PermissionUtils.permission(mPermission);
            permission.callback(new PermissionUtils.SimpleCallback() {
                @Override
                public void onGranted() {

                }

                @Override
                public void onDenied() {
                    PermissionUtils.openAppSettings();
                    Toast.makeText(MainActivity.this,"请允许权限",Toast.LENGTH_SHORT).show();
                }
            });
            permission.request();

升级调用

 //设置自定义下载文件路径
            AppUpdateUtils.APP_UPDATE_DOWN_APK_PATH = "apk" + File.separator + "downApk";
            String  desc = getResources().getString(R.string.update_content_info);
            /*
             * @param isForceUpdate             是否强制更新
             * @param desc                      更新文案
             * @param url                       下载链接
             * @param apkFileName               apk下载文件路径名称
             * @param packName                  包名
             */
            UpdateFragment.showFragment(MainActivity.this,
                    false,firstUrl,apkName,desc,BuildConfig.APPLICATION_ID,null);

termux调用执行命令

    private void launchTermux() {
        Intent intent = new Intent();
        intent.setClassName("com.termux", "com.termux.app.RunCommandService");
        intent.setAction("com.termux.RUN_COMMAND");
        intent.putExtra("com.termux.RUN_COMMAND_PATH", "/data/data/com.termux/files/home/start0");
        intent.putExtra("com.termux.RUN_COMMAND_ARGUMENTS", new String[]{});
        intent.putExtra("com.termux.RUN_COMMAND_WORKDIR", "/data/data/com.termux/files/home");
        intent.putExtra("com.termux.RUN_COMMAND_BACKGROUND", false);
        startService(intent);

        finish();
    }

判断apk是否安装

  *启动设备已安装的app
     */
    public void openTargetApp(String packageName){
        //包管理器对象
        PackageManager pm = getPackageManager();
        //检查包名
        PackageInfo packageInfo = null;
        try {
            packageInfo = pm.getPackageInfo(packageName,0);
        }catch (PackageManager.NameNotFoundException e){
            e.printStackTrace();
        }
        //包名存在则启动app
        if (packageInfo != null){
            Intent intent = pm.getLaunchIntentForPackage(packageName);
            this.startActivity(intent);
        }else{
            Toast.makeText(MainActivity.this,"应用程序未安装",Toast.LENGTH_LONG).show();
        }
    }
     

5、系统以插件形式开发
android、wordpress、termux、ubuntu集成_第3张图片

你可能感兴趣的:(git,termux)