From d4feb21868458d2db8275a7e8440922e5807ed0f Mon Sep 17 00:00:00 2001 From: lzw <lzw@github.aaej.cn> Date: 星期三, 28 二月 2024 16:09:16 +0800 Subject: [PATCH] 两次枚举 usb ,防止枚举不出来设备 --- app/src/main/java/com/fwupgrade/saymanss/HomePageActivity.java | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/app/src/main/java/com/fwupgrade/saymanss/HomePageActivity.java b/app/src/main/java/com/fwupgrade/saymanss/HomePageActivity.java index 39cb1b1..dc5c3fa 100644 --- a/app/src/main/java/com/fwupgrade/saymanss/HomePageActivity.java +++ b/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鏉ュ惎鍔ㄧ涓夋柟搴旂敤绋嬪簭鐨凪ainActivity + 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(); } -- Gitblit v1.8.0