我有两个单独的应用程序。软件包如下:
com.example.incrediblemachine.rnt
com.example.incrediblemachine.palpal
我想执行以下操作:
当单击rnt应用程序上的按钮时,我希望打开palpal应用程序。有什么办法吗?
在Button onClick()中使用getLaunchIntentForPackage方法。在此之前,请在设备/ emulator中安装com.example.incrediblemachine.palpal应用。
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.example.incrediblemachine.palpal");
startActivity(launchIntent);
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句