Code to launch external app explicitly

后端 未结 6 895
闹比i
闹比i 2020-12-01 14:21

From one of my apps, I\'m trying to launch another. I want to use an explicit intent.

ComponentName cn = new ComponentName(\"com.myOtherApp\", \"OtherAppActi         


        
6条回答
  •  情话喂你
    2020-12-01 14:40

    I had this problem and searched for hours looking for a solution. Finally found it: http://www.krvarma.com/2010/08/launching-external-applications-in-android. That link shows how to use the package manager to launch any application for which you have simply the package name:

    PackageManager pm = this.getPackageManager();
    
    try
    {
      Intent it = pm.getLaunchIntentForPackage(sName);
    
      if (null != it)
        this.startActivity(it);
    }
    
    catch (ActivityNotFoundException e)
    {
    }
    

提交回复
热议问题