How to get the apk file of a newly installed application

Put your problem here if it does not fit any of the other categories.

How to get the apk file of a newly installed application

Postby grace » Wed Apr 22, 2009 6:22 pm

Hi,

I am developing a service which detects apks installations.
When the service detects that an apk had been installed, it should take the apk file and send it to a remote server.

Currently, I was able to create a broadcast receiver that detects an installation intent (using a PACKAGE_ADDED filter), but my problem is that I don't know how to access/get the detected apk.

So my question is, how do I get the apk file that was installed when the onRecive() method is invoked?

Thanks.
grace
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sat Dec 27, 2008 8:24 pm

Top

Postby grace » Fri Apr 24, 2009 9:44 am

anyone?
grace
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sat Dec 27, 2008 8:24 pm

Postby WarrenFaith » Fri Apr 24, 2009 1:03 pm

When the service detects that an apk had been installed, it should take the apk file and send it to a remote server.

Spyware?

First: Copyright should be the first thing you should think about
Second: All downloaded apks are on the SD card in the directory "download"
Third: I would never install your service/application... its simply spyware..
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Postby grace » Fri Apr 24, 2009 3:18 pm

WarrenFaith wrote:
When the service detects that an apk had been installed, it should take the apk file and send it to a remote server.

Spyware?

First: Copyright should be the first thing you should think about
Second: All downloaded apks are on the SD card in the directory "download"
Third: I would never install your service/application... its simply spyware..


thanks for the replay, nevertheless, you should never state that some application that you don't know what it does and what's it's background is a "spyware". This is supposed to be a service that users who *want* to have their applications backed up on a remote server in order to restore their device in case something happens to the device.
A user that will install this service will know exactly what he is installing and why.

so, it might be smart not to accuse other people's application if you don't know why it is being developed.
grace
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sat Dec 27, 2008 8:24 pm

Postby WarrenFaith » Mon Apr 27, 2009 12:41 pm

First: I judge on the information you gave... if you provide information only matching spyware, its not my fault!
Second: Even if you backup it, you should care about copyright. Some licenses restrict more than a copy and just allow new download if you need it... and dont forget: i just want to help you....
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Postby grace » Mon Apr 27, 2009 4:32 pm

WarrenFaith wrote:First: I judge on the information you gave... if you provide information only matching spyware, its not my fault!
Second: Even if you backup it, you should care about copyright. Some licenses restrict more than a copy and just allow new download if you need it... and dont forget: i just want to help you....


You are right about the copyright, i will ask my instructor (it is a project that i am doing at the university...) if he had considered it.
I am sorry if I sounded offended, but it is just that this project does not intend to be harmful in any way.

I have another question: I looked into the sdcard/download directory, and I was able to see the files there, but as I understand it, there is no method/attribute that the intent has that can tell me what is the apk that was installed on the device. the intent object has a method intent.getData() which returns the package of the apk, but this is not identical to the name of the apk that is found in the sdcard/download directory.
Since that, I had to do a workaround in order to see what is the new downloaded apk, but I think that there has to be a way to know using the intent that recognized the installation what is the apk name itself.
grace
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sat Dec 27, 2008 8:24 pm

Top

Postby WarrenFaith » Mon Apr 27, 2009 5:04 pm

If you talking about the Package class, there is a method called getName() or what does the Intent.getData() gives you back?!

edit: you could also check http://developer.android.com/reference/ ... nager.html for changes...
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Postby grace » Fri May 01, 2009 1:32 pm

WarrenFaith wrote:If you talking about the Package class, there is a method called getName() or what does the Intent.getData() gives you back?!

edit: you could also check http://developer.android.com/reference/ ... nager.html for changes...


Thanks for the replay...though it is not quite what I meant.

Perhaps I am not thinking about this correctly.

I would like to be able to "hold" the apk file that was installed inside a parameter (such as java.io.file, but it would be better if android has an "apk" package api, but I haven't been able to find something like that).
That is why I wanted to search /sdcard/download for the installed file.
Unfortunately, intent.getData() retrieves the package name, which is different than the apk name installed on the sdcard, and I can't make any connection between the two (I tried to transform them to URI, but it didn't help either).
For example, I downloaded a puzzles apk from a free applications site, and the package name is:
name.boyle.chris.sgtpuzzles
while the apk name (and path) on the sdcard is:
/sdcard/download/Puzzles.apk

if i am given an apk (as a java.io.file) , isn't there a way to know it's package name?

Another thing (which is more important to me, since I have already created a work-around for the previous problem): how can I get the signature of an apk?
I want to send the signature to the server as a mean of saving redundant communication time (in case that the user had already backed up his application on the server), so i want to use the signature as a hash-code that gives me a short (sort of) unique representation of the file.
I was able to get the signers of a class, but not it's signature... I saw that android has a signature class, but I don't understand how can I use it.


many many thanks.
grace
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sat Dec 27, 2008 8:24 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 13 guests