我有兩個應用程式(appA 和 appB)。我想檢索存盤在其中的單個值appA sharedPreferences并在 appB 中使用它。我可以使用意圖來做到這一點嗎?我只需要執行一次(在第一次安裝 appB 時)。
uj5u.com熱心網友回復:
您應該能夠將其添加.putextras()到您的意圖中,然后getExtras()在 appB 上使用它們(在檢查它們是否存在之后)。
檢查此答案以供參考https://stackoverflow.com/a/5265952/10637400
uj5u.com熱心網友回復:
使用 Intent 在 appA 中啟動 appB
// Launch appB in appA
Intent intent = context.getPackageManager().getLaunchIntentForPackage(appB_PackageName);
intent.putExtra("key","value");
startActivity(intent);
或者在appB Android中讀取sharedPreferences : Retrieving shared Preferences of other application
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/310822.html
