2012-10-11 42 views
0

我們可以通過點擊某個活動中的按鈕來啓動憤怒的小鳥遊戲嗎? 我可以通過點擊按鈕在我的活動中啓動閱讀器活動。 而且我知道我們可以從一個包到另一個包啓動活動。 代碼如下爲憤怒的小鳥和讀者 我能夠啓動讀者,我不知道爲什麼我不能發射憤怒的小鳥?發起不同的活動?

代碼憤怒的小鳥是如下..

Intent intent = new Intent(); 
      intent.setAction(Intent.ACTION_VIEW); 
      intent.setAction(Intent.ACTION_MAIN); 
      intent.addCategory(Intent.CATEGORY_LAUNCHER); 
      ComponentName cn = new ComponentName("com.rovio.angrybirds","com.rovio.ka3d.app"); 
      intent.setComponent(cn); 
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
      startActivity(intent); 

規範書redear如下..

Intent intent = new Intent(); 
      intent.setAction(Intent.ACTION_VIEW); 
      intent.setAction(Intent.ACTION_MAIN); 
      intent.addCategory(Intent.CATEGORY_LAUNCHER); 
      ComponentName cn = new ComponentName("com.bluefirereader","com.bluefirereader.BookActivity"); 
      intent.setComponent(cn); 
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
      startActivity(intent); 

請幫助me..Thanks提前

回答

0

我解決方案。事實上,我以前使用的代碼是正確的。而事情是組件信息,我給的意圖是錯誤的。代碼如下:

Intent intent = new Intent(); 
     intent.setAction(Intent.ACTION_VIEW); 
     intent.setAction(Intent.ACTION_MAIN); 
     intent.addCategory(Intent.CATEGORY_LAUNCHER); 
     ComponentName cn = new ComponentName("com.rovio.angrybirds","com.rovio.ka3d.App");//Here erlier I put com.rovio.ka3d.app instead of com.rovio.ka3d.App 
     intent.setComponent(cn); 
       intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
     startActivity(intent);