2010-10-25 75 views
0

我在一個活動中有一個處理程序,並且我想使用sendBroadcast來啓動另一個應用程序(不同的APK)的接收程序。處理程序中的廣播意圖

我無法做到這一點,因爲我進入一個處理程序,我失去了我的活動範圍。

任何想法我怎麼能實現這個想法?

一些代碼:

private Handler mHandler = new Handler() { 
    public void handleMessage(Message msg) { 
     switch (msg.what) { 
      case INSTALL_COMPLETE: 
       // here I wanna start my extern application via broadcasting!! 

       startApplication(); 
       break; 
      default: 
       break; 
     } 
    } 

如果廣播不會通過處理工作,任何其他的想法將受到歡迎,

感謝。

回答

0

這是我的錯誤, 我可以在Handler中使用startBroadcast/application/service。

無論如何感謝:

private final int INSTALL_COMPLETE = 1; 
private Handler mHandler = new Handler() 
{ 
    public void handleMessage(Message msg) 
    { 
     switch (msg.what) 
     { 
      case INSTALL_COMPLETE: 

       // finish the activity posting result 
       // setResultAndFinish(msg.arg1); 
       startApplication(); 
       break; 
      default: 
       break; 
     } 
    } 

    private void startApplication() 
    { 
     String intentName = g_szIntentName; 
     Intent i = new Intent(intentName); 
     i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
     sendBroadcast(i); 
    } 
};