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

JLabel background distorts while using JXDatePicker
Error creating bean - Spring Boot
Android ListView how can I get the value of each individual row
what is need of service layer in spring mvc ? what kind of logic recommended?
Is it possible to generate html file with angularjs script using server side java program?
How to analyze performance of Objectify?
How to transform the key and value of a each entry set of a Map using Java 8?
How do i change the printing output for an enum, as enum values are all upper case [duplicate]
Sum of the difference of pairs of numbers in an array - Java
Is there a Java library which is similar to the C# WSTrustChannelFactory
Not able to delete image file using JAVA
[HELP]filters in the spatial domain[JAVA]
java public field when inherit [duplicate]
Send gmail using java with service account setup for OAuth
How to redirect select queries to replicated database using non-jta-data-source in Spring application
Get data from combobox to database

Categories

HOME
yii2
gitlab
proxy
mediawiki
pycharm
vmware
react-router
youtube-dl
amortized-analysis
sharepoint-designer
jpeg
jxls
podio
webrequest
modx-revolution
windows-phone-7
event-handling
quartz-scheduler
telephony
xlsxwriter
scriptcs
graphicsmagick
dcevm
extjs5
realex-payments-api
info.plist
opentype
large-file-upload
socialengine
javascriptcore
webtest
vsts-build-task
uiswipegesturerecognizer
form-data
nssegmentedcontrol
io-redirection
twitch
webix-treetable
hp-ux
janrain
mime
menuitem
jsch
filepicker
termination
clean-architecture
gabor-filter
mplayer
jxcore
snmptrapd
pdfclown
pintos
jquery-filter
heidisql
removechild
database-optimization
transmitfile
storekit
websitepanel
react-native-listview
qcustomplot
apachebench
system.management
unity-networking
rtbkit
ios8-today-widget
srand
prerequisites
metaclass
jmeter-maven-plugin
spidermonkey
varargs
riak-cs
sailfish-os
operator-precedence
id3v2
mechanize-ruby
bundles
farseer
ivyde
ccss
dexterity
quartz-graphics
ril
xamlparseexception
plasma
eventlistener
smtp-auth
wsdl-2.0
typoscript2
bitsharp
rdoc
funscript
javaspaces
tridion-worldserver
getmessage
parametric-equations
qt-jambi
disclosure
coda-slider
gallio
.nettiers
uimenucontroller
swing-app-framework
port-number
genealogy
ugc





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