1

When we click the widget at that time i need to open an external aplication (for example netflix app).How to do this?

In all cases i find solutions like that but, is not what I'm looking.

Thanks!!

Community
  • 1
  • 1
Musculaa
  • 934
  • 10
  • 19
  • 1
    You can see http://stackoverflow.com/questions/8969242/how-to-make-widget-of-running-application-in-android. –  Mar 18 '14 at 16:07
  • 1
    Then what do you want? Please post the exact requirement... – Viral Patel Mar 18 '14 at 16:40
  • Please explain more... – S.M_Emamian Mar 18 '14 at 16:55
  • Please explain what "not what I'm looking" means. – CommonsWare Mar 18 '14 at 16:59
  • 2
    The exact requirement: open an external application from my own android widget. I edited the post to show an example. Obviously it's only the image, because i need open the real netflix application in the code. –  Mar 18 '14 at 17:16
  • 2
    When i say "not what I'm looking" i say that because in the typical solution, you need know the PackageName and the start activity name, to link the widget to the app. But i don't know this information for external apps. –  Mar 18 '14 at 17:28

2 Answers2

2

Try this but you should know the package name of that another application

  PackageManager pm = getPackageManager();
  try
  {
   String packageName = "com.example.package";
   Intent launchIntent = pm.getLaunchIntentForPackage(packageName);
   startActivity(launchIntent);
  }
catch (Exception e1)
{
}

EDIT:

To check the package name of the application, open your file explorer and go to directory called android\data\ here you will find package names of all installed apps

Praveena
  • 6,340
  • 2
  • 40
  • 53
1

To create your own widget for external apps, you can use this code:

PackageManager pm = getPackageManager();
      try
      {
       String packageName = "com.example.package";
       Intent launchIntent = pm.getLaunchIntentForPackage(packageName);
       startActivity(launchIntent);
      }
    catch (Exception e1)
    {
    }

So if you need the package name you can find it in a web browser, in google play site. enter image description here

and then, just remplace it in the code: String packageName = "com.netflix.mediaclient";