lzw
2024-02-28 d4feb21868458d2db8275a7e8440922e5807ed0f
app/src/main/java/com/fwupgrade/saymanss/HomePageActivity.java
@@ -2,6 +2,7 @@
import android.Manifest;
import android.annotation.TargetApi;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -22,6 +23,7 @@
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.fwupgrade.saymanss.adapter.FwFileListAdapter;
import com.fwupgrade.saymanss.deviceplug.IUsbDevicePlugDelegate;
@@ -217,6 +219,33 @@
        UStorageTestModule.getInstance().initUStorageDeviceModuleWithVirtualDisk(AppPathInfo.getLogPath());
    }
    public void openThirdPartyApp(String pkgName) {
        try {
            // 替换为第三方应用程序的包名和MainActivity的完整类名
            String mainActivityName = pkgName+".MainActivity";
            // 创建Intent来启动第三方应用程序的MainActivity
            Intent intent = new Intent();
            intent.setComponent(new ComponentName(pkgName, mainActivityName));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            // 启动Intent
            startActivity(intent);
        } catch (Exception e) {
            // 处理异常情况,例如应用程序未安装等
            e.printStackTrace();
            Toast.makeText(this, "无法启动第三方应用程序", Toast.LENGTH_SHORT).show();
        }
    }
    @Override
    protected void onResume() {
        super.onResume();
        //
//        openThirdPartyApp("safeluck.drive.training");
    }
    @Override
    protected void onNewIntent(Intent intent) {
        Log.d(TAG, "onNewIntent");
@@ -226,6 +255,7 @@
    @Override
    protected void onDestroy() {
        Log.i(TAG,"onDestroy");
        super.onDestroy();
    }