java


How to get Application Installation failed event in app


I have been using Action_View to install apk using following code
Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
intent.setDataAndType(Uri.fromFile(new File(location + "myAPK.apk")),
"application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
It opens the Install Prompt window in device. Now user can install or cancel the installation process.
I am only interested when user click the install package but installation failed due to some reason may be corrupt apk or mismatched signed apk etc.
How can i capture the event when installation failed.. Can i get the result from ACTION_INSTALL_PACKAGE
I have gone through reading System Broadcast Messages but all are used for either Pacakge added or replaced.
Any Clue ?
Launch the Intent with startActivityForResult:
Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
intent.setDataAndType(Uri.fromFile(new File(location + "myAPK.apk")),
"application/vnd.android.package-archive");
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
startActivityForResult(intent, MY_CONSTANT);
Then analyse the result
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case ...
}
}
Quoting the documentation for ACTION_INSTALL_PACKAGE:
Output: If EXTRA_RETURN_RESULT, returns whether the install succeeded.
Quoting the documentation for EXTRA_RETURN_RESULT:
Used as a boolean extra field with ACTION_INSTALL_PACKAGE or ACTION_UNINSTALL_PACKAGE. Specifies that the installer UI should return to the application the result code of the install/uninstall. The returned result code will be RESULT_OK on success or RESULT_FIRST_USER on failure.
So, add EXTRA_RETURN_RESULT to your Intent, with a value of true, and use startActivityForResult().

Related Links

Why defensive copying with clone represents a security issue?
What Data Structure is Being Used in this Algorithm?
Combine 2 arrays
facebook real time update in java example
Head First Android Development - RSS Feed
Adding Image to 2d Game in Android?
Page Object Pattern with TestNG [duplicate]
No results returned by SimpleJdbcCall that executes Oracle function returning a REF CURSOR
Android - How to know when device is flat to ground or not?
Java JDBC web MySql communication
Read Different Entries from File in Java
Method read from file using java language
why javax.servlet-api doesn't contain jstl?
Catching exception types twice
How can I get a direction with latitude and longitude in Android?
Correct place to catch out of memory error

Categories

HOME
yii2
client
atom-editor
hook
debugging
amazon-ec2
oracle11g
angular-material
electron
sd-card
spagobi
rsyslog
at-command
amortized-analysis
jpeg
binary-tree
acquia
indesign
django-imagekit
vault
midi
resize
php-7.1
circular-dependency
msp430
worldwind
introduction
swingx
excel-2007
extjs5
cultureinfo
shopware
chromebook
nhapi
social-media
maxmind
maquette
buck
webkitspeechrecognition
vision
quote
google-rich-snippets
lxd
xmlreader
force-layout
environment-modules
picasso
ios5
appfabric
devextreme
dartium
x11-forwarding
objectlistview
ssjs
mesos-chronos
flickr-api
rainbowtable
python-webbrowser
winscp-net
dropbox-php
quartz-composer
parallel-data-warehouse
libpng
rotativa
ctest
mongocsharpdriver
multiple-regression
jwplayer7
independentsoft
spim
wso2cloud
prerequisites
intellij-14
clipperlib
fscommand
website-monitoring
pick
coldbox
asp.net-dynamic-data
java.util.concurrent
nsbutton
zend-route
openexr
htmlcleaner
hyprlinkr
app42
message-driven-bean
farseer
ccss
commoncrypto
cdc
gridfs
apc
quartz-graphics
gridcontrol
datawindow
javaspaces
twrequest
jspinclude
code-cleanup
spyware
table-footer
winbugs14
android-sdk-2.1
xsdobjectgen
modelstate
perfect-hash
anti-piracy
noscript
data-acquisition

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