android


How to get package name of any application after successful installation in android? [duplicate]


This question already has an answer here:
How to get package name from apk in Android?
2 answers
I am devloping an app that contain list of app ,what I have to do is when user click on particular app he will be redirected to google play store and after successful download of that app I have to get package name of that app for this I am using broadcast receiver.But this receiver get package name of every app whenever new app is download in device .But I only want to get package name of that app which is listed in my app .
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
PACKAGE_NAME = getApplicationContext().getPackageName();
}
List<ApplicationInfo> packages;
PackageManager pm;
pm = getPackageManager();
//get a list of installed apps.
packages = pm.getInstalledApplications(0);
ActivityManager mActivityManager = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
for (ApplicationInfo packageInfo : packages) {
PAKAGE_NAME = packageInfo.packageName contains package name
}
Use getPackageManager().getPackageInfo(getPackageName(), 0).packageName
You can also create a function for this:
public String getPackageName(Context context) {
return context.getPackageName();
}

Related Links

How to connect android with .net webservice
About GCM support period
Error while importing Eclipse project to Android Studio for support lib. v7
updateChildren not updating the children?
android ui design varies for the same dimensions but the screen sizes are different which devices are having hardware menu button
Landscape mode issue in draggable panel library
AlarmManager schedule to run every 10 minute from 9AM to 4PM
Candidate view is working but it's not set properly place in KeyboardView
Estimote Beacon not able to detect in android
Android Fragment Back Stack
SetBackgroundColor for Button from Resource file in Xamarin (Android)
Android package manager - install and open APK
how to select one row's position in a list-view not by ItemIdAtPosition?
Add a CompassOverlay and get errors
Android show crouton layout below Toolbar
Get random images in Android Studio

Categories

HOME
sonarqube
c99
gpu
pda
angular2-material
jmx
serialization
jelastic
composite-primary-key
vscode-extensions
aws-cli
simulink
pearson-correlation
vimdiff
distribution
entitymanager
joptionpane
aggregation
epsilon
interpreter
soot
realm-mobile-platform
zend-debugger
github3.py
android-maps-extensions
fossil
latitude-longitude
lint
openalpr
git-rewrite-history
projects-and-solutions
apns-php
p4merge
wmp
subclipse
jide
pom.xml
openrasta
twilio-click-to-call
openblas
carrot2
ngmaterial
cup
otp
java-websocket
cpu-cache
structuremap4
dotnetnuke-7
uicolor
x-tag
eigenvector
android-wake-lock
http-status-code-401
nss
tracker-enabled-dbcontext
data-protection
gcloud-ruby
dbamp
sciruby
computer-architecture
fuelcms
evolus-pencil
eoferror
ocra
mirror
apache-commons-daemon
telepat
android-broadcast
fits
cakephp-2.7
gamekit
openbabel
procedural-programming
beatsmusic
contrast
cocos3d
tweenlite
mobility
build-script
amslidemenu
xmltodict
ecslidingviewcontroller
windows-phone-8-sdk
ice-cube
abstract-data-type
onload-event
redis-py
node-redis
user-tracking
workflow-services
uipagecontrol
maven-1
jqueryform
addchild
mathematical-notation
fail-fast-fail-early
application-planning
sqlobject

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App