從A程序跳轉至B程序
首先在目標APP的清單配置文件manifest中的主Activity中添加:
android:exported="true"其次在A程序的跳轉監聽中添加如下代碼:
ComponentName c =new ComponentName("com.*******.*******", //目標應用包名 "com.*******.*******.TargetActivity"); //目標應用Activity包名.類名 TargetActivity manifest中需要配置: //<intent-filter> //<action android:name="android.intent.action.MAIN"/> try { intent = new Intent(); intent.setComponent(c); startActivity(intent); } catch (Exception e) { Log.i("tag", e.toString()); Toast.makeText(getApplicationContext(), "未找到可用應用程序!", Toast.LENGTH_LONG).show(); }