打开其他应用的Activity的稳妥方法
- - 移动开发 - ITeye博客如题,为了避免异常,也就是说如果那个Activity不存在,或者启动失败,那么会导致异常,稳妥的方式如下:. 已有 0 人发表留言,猛击->> 这里<<-参与讨论. —软件人才免语言低担保 赴美带薪读研.
Intent intent = new Intent(); intent.setClassName("setting.ui", "setting.ui.VrActivity"); if (getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) { try { startActivity(intent); } catch (ActivityNotFoundException e) { Log.d(TAG, "Can't find activity " + e.getMessage()); } catch (Exception e) { Log.d(TAG, "Can't find activity Exception : " + e.getMessage()); } } else { Log.d(TAG, "Can't find activity"); }