android - Pasing data through app after install without launching -
refering this post need ask else.
i have application "a" download , install app "b".
want b "transfer" data a , a use data work.
i know can transfer data intent
.
after installing b app a, android provide choice "ok" or "launch" ; question :
- is possible pass data b a when click on "ok"? (so stay in a app without launching b)
- if yes, how? possible "invisible" launch b? how should code b comportement?
i know might hard understand, can try check previous draw (here again).
edit:
i use code launch b installation a.
intent intent = new intent(intent.action_view); intent.setflags(intent.flag_activity_new_task); uri uri = uri.fromfile(new file(environment.getexternalstoragedirectory().tostring() + "/downloadedfile.apk")); intent.setdataandtype(uri, "application/vnd.android.package-archive"); getapplicationcontext().startactivity(intent);
there many ways handle this, here 1 (i believe) quite simple implement. since app [presumably] knows installing:
app a: add broadcastreceiver
react installation, though default off.
android: broadcastreceiver on application install / uninstall
app b: add service
background communication.
note:
service
must exported accessible other apps via explicit intent, creates security concern, open all other apps.
when user of app clicks install app b:
start broadcastreceiver
filter set detect install: stackoverflow...android-broadcastreceiver-on-application-install-uninstall
app starts install.
when broadcastreceiver
detects package has been added (the package name in received intent,) can stop broadcastreceiver, , can send explicit intent
naming service in appb. can pass whatever data need in intent.
when appb service receives intent, can act in way you'd like.
service created using non-null intent, though 'action' of explicit intent
s null. service.onstartcommand() might receive null intent if service re-created.
i'd fill in more of code, have day job ;)
note:
intent.action_package_added called when package installed.
intent.action_package_install never used, , deprecated in api 14.
http://developer.android.com/reference/android/content/broadcastreceiver.html http://developer.android.com/reference/android/content/intent.html
Comments
Post a Comment