1.打开二级菜单apps界面有概率崩溃,getActivity()为空

This commit is contained in:
2026-02-07 14:14:22 +08:00
parent 27457cf8ce
commit 25c77aad68
2 changed files with 9 additions and 1 deletions

View File

@@ -84,4 +84,11 @@ public class FragmentManager {
public void destory(){
mInstance = null;
}
public String getPackageName(){
if(mContext!=null){
return mContext.getPackageName();
}
return "";
}
}

View File

@@ -13,6 +13,7 @@ import com.android.nebulasdk.AppManager;
import com.android.util.IntentUtil;
import com.android.util.LogUtils;
import com.ik.mboxlauncher.R;
import com.ik.mboxlauncher.ui.FragmentManager;
import com.ik.mboxlauncher.ui.adapter.MyAppInfoAdapter;
import java.util.ArrayList;
@@ -72,7 +73,7 @@ public class AppsFragment extends CategoryFragment {
List<AppBean> appBeanList = (List<AppBean>) data;
// 创建过滤后的列表
List<AppBean> filteredList = new ArrayList<>();
String selfPackageName = getActivity().getPackageName();
String selfPackageName = FragmentManager.getInstance().getPackageName();;
for (AppBean appBean : appBeanList) {
// 跳过自身应用