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

“A connector with id is already registered! ” in vaadin
JSON Array of objects to plain old java object
How to read and display the contents of a text file chosen from a file chooser in android app?
Pass JsonResponse to IntentService
Why is Jackson writing the same JSON key/value twice?
Set timeout to WS https call in Spring (HttpsUrlConnectionMessageSender)
How to mockup in Java POJO calling JAX-RS Web service with #OPTIONS annotation
How to put elements into String array?
AtomiceInteger is not increased as expected with forjointask
Many to many relationship with additional created Timestamp column in JPA 2.1
How to mock an interface's reference which is initialized by MyBatis?
JOptionPane Issue in Eclipse
Spring Boot Actuator Endpoint Override
Testing Android Apps with hardware component
Running linux command in java
Embedding Transitive Dependencies in OSGI

Categories

HOME
java
osgi
clips
debugging
openstack
gremlin
react-virtualized
session
relay
paw-app
retrofit
contact
cloudkit
windows-10-universal
wheelnav.js
undefined
django-cms
immutable.js
jasonette
kvc
opennlp
user-interaction
bootstrap-material-design
nhapi
greendao
fluentvalidation
elasticsearch-ruby
log4js-node
subdomains
objectanimator
ecto
grails-3.1
dynamics-crm-2013
twitch
leading-zero
graphenedb
gzipstream
quadratic-programming
node-gyp
galleria
apple-news
smartcontracts
komodoedit
qsslsocket
kbuild
crypt
namecoin
pdfclown
pycaffe
spring-android
gridpane
measures
ctest
markojs
simplewebrtc
hover-over
ios4
historian
citrus-pay
jqgrid-formatter
ideamart
notify
apache-commons-net
c++03
npapi
csquery
java-metro-framework
gulp-less
tld
jquery-layout
hippomocks
android-2.2-froyo
stxxl
floating-point-precision
tidy
google-cloud-save
ril
eventlistener
html-editor
enterprisedb
angularjs-controller
sublist
trusted
newtonscript
chrono
buildr
amazon-appstore
spring-portlet-mvc
asyncfileupload
mercurial-server
xmlspy
self-extracting
pyinotify
site.master
suppress
getresponsestream
routedevent
web-architecture
anti-piracy
w3wp

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