重複啓動某一款應用,並傳遞intent參數

        Intent intent = getPackageManager().getLaunchIntentForPackage(packageName); 
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); 
        
        switch (v.getId()) {
            case R.id.btnOpen1:
                intent.putExtra("roomid","1");
                startActivity(intent);
                break;
            case R.id.btnOpen2:
                intent.putExtra("roomid","2");
                startActivity(intent);
                break;
        }
相關文章
相關標籤/搜索