How to get Package Name from API

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

How to get Package Name from API

Postby c3r13e12u5 » Wed Nov 12, 2008 11:38 am

hi All,

I created an API and now my game is using that API.
but in the API i want to get the game's packageName or getPackageCodePath.
how can I achieve that?

thanks.
c3r13e12u5
Developer
Developer
 
Posts: 28
Joined: Wed Oct 08, 2008 7:33 am

Top

Postby c3r13e12u5 » Tue Nov 18, 2008 11:20 am

bump!
c3r13e12u5
Developer
Developer
 
Posts: 28
Joined: Wed Oct 08, 2008 7:33 am

Postby paxus » Wed Nov 19, 2008 3:14 pm

myObject.getClass().getCanonicalName() shows full class name with package
paxus
Freshman
Freshman
 
Posts: 2
Joined: Wed Nov 19, 2008 3:12 pm

Postby c3r13e12u5 » Thu Nov 20, 2008 3:01 am

Thank you for the answer paxus.

but it still does not solve my problem.
"getCanonicalName()" only returns me the package name where the code was placed such as "com.api.io".
the one i need is game's package name which is the .apk path such as "/data/app/com.demo.apk".
actually I want to get the .apk url without using Activity object. because the API is precompiled before the game it self.
c3r13e12u5
Developer
Developer
 
Posts: 28
Joined: Wed Oct 08, 2008 7:33 am

Postby alpesh_harsoda » Thu Nov 20, 2008 9:05 am

what if i want to get full path of apk file.?
any idea? :o
Regards,
Alpesh Patel,
Logistic Infotech
http://www.logisticinfotech.com
User avatar
alpesh_harsoda
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat Sep 20, 2008 12:35 pm
Location: Rajkot,Gujarat(India)

Postby paxus » Thu Nov 20, 2008 9:13 am

So, actually, you need to find out not a package name, but apt-file in file system, which contains loaded class, don't you? In that case it's deal of ClassLoader. It loads first class that can be found in classpath, and it only knows where file is located.
I'm not familiar with android framework, and you have to investigate yourself whether its classLoader stores this information or not. In case it doesn't you would have to implement some kind of workaround... or replace system classLoader with your implementation.
paxus
Freshman
Freshman
 
Posts: 2
Joined: Wed Nov 19, 2008 3:12 pm

Top

Postby alpesh_harsoda » Thu Nov 20, 2008 9:17 am

hi thnks for reply
actually i m running my one application from that if i want to start second application then means from one apk to another apk then i have to retrieve the path of second apk.
so i dont know how to retrieve the path of apk.
Regards,
Alpesh Patel,
Logistic Infotech
http://www.logisticinfotech.com
User avatar
alpesh_harsoda
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat Sep 20, 2008 12:35 pm
Location: Rajkot,Gujarat(India)

Postby MrSnowflake » Thu Nov 20, 2008 1:45 pm

You can't ge the .apk path from the device, as the apk file is only an installer, and it will install the package on your phone in it's designated directory. So the apk itself is only used for installation.

What you want to start a second application(/task)? And you try to do it with the apk's name? Am I wrong, or didn't you get the the concept of Intents?
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby c3r13e12u5 » Mon Nov 24, 2008 2:34 am

You are right Paxus, Im looking for the apt url that loads this class.
I will try to search on the ClassLoader, thanks for your advise.
c3r13e12u5
Developer
Developer
 
Posts: 28
Joined: Wed Oct 08, 2008 7:33 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 17 guests