Charan Pai
Charan Pai

Reputation: 2318

how can i get to know which app package is startig my activity?

there are many applications which invokes my application in system> I want to know which app invoked my app or activity or service presently ?

Can anybody help me to solve this ?

Upvotes: 1

Views: 210

Answers (2)

KunalK
KunalK

Reputation: 1904

In the starting activity of your application you can try following code to get the PackageName of the app that invokes your application.

if(getIntent().getPackage()!=null){
   String packageName = getIntent().getPackage();
}

Upvotes: 1

omermuhammed
omermuhammed

Reputation: 7385

You can provide different activities to start your app, each being called by different apps. Or you can monitor user actions after app launch (navigation to screens etc) and determine which application may have launched your app. These two are relatively logical but apart from this you can monitor and look for currently running apps (look here for one possible way to do that) and then maybe determine which application launched your app.

Note that these are just strategies, not a definite answer.

Upvotes: 0

Related Questions