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

Android Development Lifecycle Setup
Second activity re-appearing after using statrtactivityfor result and closed
Open URL in Android App?
listview with checkboxes and without
how to apply Discrete wavelet transform on image
Problems with SQLite in Android
Is there a way to add a seekbar to my actual preference screen?
Get RawContactId of specific Contact based off PhoneLookup
Bitmaps on canvases a bad idea for any game with moving objects
Which Android platform SDK do I need?
How to implement a changelog in android?
How to get the speaking sound that comes from the phone user and convert to byte array ?
How can i change image at run time ?
Can multiple lists be treated as fragments in Android?
Code does not extend ListViewActivity, but does have a listview
Calling a EditText field into focus

Categories

HOME
windows
go
azure-stream-analytics
developer-tools
depth
interface
spring-data-mongodb
alsa
cq5
visual-studio-emulator
square
vsm
octave
dkim
text-mining
startup
selenium-ide
docx
package-managers
video-editing
smartclient
foreign-keys
asciidoctor-pdf
springfox
libigl
interpreter
direct3d11
draft-js-plugins
gpio
mockjax
clickjacking
slacktextviewcontroller
baidu-map
loading
cin
apache-stanbol
trigonometry
visa
android-softkeyboard
print-css
x++
rserve
tf
dt
ampps
bootstrap-tags-input
sandcastle
rmongo
cubism.js
microstation
rspec2
x-tag
udpclient
spreadjs
hadoop-partitioning
ikiwiki
uiactionsheet
invoke-sqlcmd
jaunt-api
ascii-art
crouton-os
asyncdisplaykit
vhosts
character-replacement
assertion
grgit
branch-and-bound
matlab-deployment
mass-assignment
entry-point
device-tree
wxformbuilder
decoupling
accesscontrolexception
windows-embedded-standard
mysql-error-1044
ie8-compatibility-mode
windows-phone-8-sdk
jquery-1.9
http-status-code-410
swfobject
apache-abdera
extreme-programming
vfs
boost-signals
thttpd
urlrewriter
winmain
lr
pylucene
http-daemon
vs-android
echo3
wcf-instancing
cuda.net
complex-event-processing
localizable.strings

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