Hi calle, I also tried to install application but get package parsing
error. Can't we use file:///data/data/package/files/application.apk.
I  downloaded file /files but I cannot install it. Installation code
is below.What may be problem?
                 String packageName=this.getPackageName() ;
         String fileName ="file:///data/data/"+packageName+"/files/
Button5.apk";
         File apkFile = new File(fileName);
                  Intent intent = new Intent(Intent.ACTION_VIEW);
                  intent.setDataAndType(Uri.fromFile(apkFile),
"application/vnd.android.package-archive");
                startActivity(intent);

On 13 Temmuz, 16:27, calleandersson <[email protected]>
wrote:
> Hi Justin,
>
> Thanks for your answers.
>
> I didn't realize that a file was be placed in the private directory
> when using MODE_WORLD_READABLE. I've been testing using the mode you
> suggested and this seems to work as intended (meaning, the system
> install UI is invoked and the application can be installed).
>
> I still have some questions though.
>
> Where is the private directory of an application located? Is it
> located in the phone memory or some kind of hidden files on the memory
> card?
>
> I discovered an article (http://strazzere.com/blog/?p=185) which
> described a problem with the Android Market. I suppose that something
> has been done to prevent the problem but is this something that could
> be done to every private directory or was it just an application
> specific problem?
>
> If my client install an application from an .apk file and then remove
> that .apk file, is it still possible for an user to somehow retreive
> or copy the application and use it on another device? What if the .apk
> file isn't removed?
>
> Regards,
> Calle
>
> On 6 Juli, 19:39, "Justin (Google Employee)" <[email protected]> wrote:
>
>
>
> > > > How does the process for retrieving system rights look like?
>
> > Its a matter of signatures. Whoever signs the system is also going to
> > need to sign any app that wants system privileges.
>
> > > I suppose this problem
> > > shouldn't exist if I was able to save the .apk file in the private
> > > directory of my application and then invoke the system install UI on
> > > the file.
>
> > Well, no, you can't have your cake and eat it to. The package manager
> > needs to be able to read the APK file to install the app. In order to
> > do this you need to place the APK in a world-readable location because
> > you can't have the same UID or GID as the package manager. No matter
> > what you do, if you want to allow the package manager to read the
> > file, everyone can. Now, if you put the file in your private directory
> > and set the mode to MODE_WORLD_READABLE, the package manager may be
> > able to read the file, I think it should be able to. Everyone else
> > can, but they would have to know the exact path because I don't
> > believe they can list the directory in which the file resides.
>
> > Now, regardless of where the APK is placed, you should probably delete
> > it after installation, otherwise you're at least doubling storage
> > space required per application. If you delete the APK after its
> > installed, you also fix your "install only to device downloaded on".
>
> > Cheers,
> > Justin
> > Android Team @ Google
>
> > On Jul 2, 3:48 am, calleandersson <[email protected]> wrote:
>
> > > I have been testing with the 'file://' prefix and got the following
> > > results:
>
> > > When saving an .apk file in the private directory of my application
> > > and trying to invoke the system installation UI, an parse error
> > > occured due to permission issues:
> > >   07-02 07:15:27.826: WARN/zipro(726): Unable to open zip '/data/data/
> > > test.calle.helloworld/files/AndroidHelloWorld.apk': Permission denied
> > >   07-02 07:15:27.826: DEBUG/asset(726): failed to open Zip archive '/
> > > data/data/test.calle.helloworld/files/AndroidHelloWorld.apk'
> > >   07-02 07:15:27.846: WARN/PackageParser(726): Unable to read
> > > AndroidManifest.xml of /data/data/test.calle.helloworld/files/
> > > AndroidHelloWorld.apk
> > >   07-02 07:15:27.846: WARN/PackageParser(726):
> > > java.io.FileNotFoundException: AndroidManifest.xml
> > >    ...
> > >   07-02 07:15:27.856: WARN/PackageInstaller(726): Parse error when
> > > parsing manifest. Discontinuing installation
>
> > > When I saved the .apk file on the SD card, everything went as supposed
> > > and the system installation UI was displayed.
>
> > > So far so good. However, I only want a downloaded .apk file to be
> > > installed on the same phone which downloaded it. If the application is
> > > placed on the SD card, wouldn't it be possible to use the same SD card
> > > in another phone (or copy the .apk file to another SD card used by
> > > another phone) and install the application on that phone too? Am I
> > > correct in these assumtions?
>
> > > With regards to what I wrote above, is it somehow possible to restrict
> > > an application file from beeing installed on any other phone except
> > > the very same phone which downloaded the .apk file (using my
> > > application)? Is system rights needed? I suppose this problem
> > > shouldn't exist if I was able to save the .apk file in the private
> > > directory of my application and then invoke the system install UI on
> > > the file.
>
> > > Regards,
> > > Calle
>
> > > On 1 Juli, 18:22, calleandersson <[email protected]> wrote:
>
> > > > Hi Justin,
>
> > > > Thanks for the tips about the 'file://' prefix and SD card, I will
> > > > look into that tomorrow.
>
> > > > How does the process for retrieving system rights look like? Is it the
> > > > manufacturer of an Android device which decides if an application
> > > > should have system rights? I suppose that that kind of clients must be
> > > > installed/included in the device before it is released or am I wrong?
>
> > > > Is there somehow possible to simulate that an application has system
> > > > rights in the Emulator?
>
> > > > By the way, I was thinking of using the same Intent code to start an
> > > > already installed application but, currently, I'm using the following
> > > > code which seems to work pretty well (and the class name doesn't need
> > > > to be specified):
> > > > Intent intent = getPackageManager().getLaunchIntentForPackage
> > > > (packageName);
> > > > startActivity(intent);
>
> > > > Regards,
> > > > Calle
>
> > > > On 1 Juli, 17:18, "Justin (Google Employee)" <[email protected]> wrote:
>
> > > > > The package manager way will not work, you need the permission you
> > > > > referenced, INSTALL_PACKAGES, which only the system has and is not
> > > > > obtainable by user-installed applications.
>
> > > > > I think your Intent-based method should work, I believe this is more
> > > > > or less what the browser does when you download an APK from the
> > > > > internet. I have two thoughts. First, you haven't specified a proper
> > > > > Uri, you've specified a file path, try file:///data/data/... Second,
> > > > > I'm not sure you can place the file in your app's private directory
> > > > > and have this work, to remove this variable, try placing the APK on
> > > > > the SD card.
>
> > > > > As far as removing packages, I'm not sure, I'm not sure what Intent
> > > > > you would use to do this, although certainly some Intent exists,
> > > > > albeit probably private/undocumented. You could watch the logcat
> > > > > output when you go into the application manager from settings.
>
> > > > > Cheers,
> > > > > Justin
> > > > > Android Team @ Google
>
> > > > > On Jul 1, 6:22 am, calleandersson <[email protected]> wrote:
>
> > > > > > Hi,
>
> > > > > > I am going to create an application (using Android 1.5) which can
> > > > > > download and install other applications and also be able to remove
> > > > > > these applications when needed. I have tried to do this in two
> > > > > > different ways but havn't had any success:
>
> > > > > > -- A: the PackageManager way --
>
> > > > > > Using the following code:
>
> > > > > > getPackageManager().installPackage(Uri.parse(url));
>
> > > > > > an SecurityException occur since (as I understand) it isn't possible
> > > > > > for an application to be granted the INSTALL_PACKAGES permission
> > > > > > (which is needed by the installPackage() method) unless the program
> > > > > > has system rights.
>
> > > > > > A1. Is it correct that system rights is needed by an application to 
> > > > > > be
> > > > > > granted INSTALL_PACKAGES permission?
>
> > > > > > A2. How can an application acquire system rights?
>
> > > > > > A3. Will this approach generate some kind of platform specific 
> > > > > > install
> > > > > > popups (or something like that) or could an application be installed
> > > > > > without any user interaction required?
>
> > > > > > -- B: the Intent way --
>
> > > > > > I download an .apk-file using code similar to the following code:
>
> > > > > > URL sourceUrl = new URL(source);
> > > > > > Object data = sourceUrl.getContent();
> > > > > > String fileName = sourceUrl.getFile().substring(fileName.lastIndexOf
> > > > > > ('/') + 1);
> > > > > > // create/open file in the 'data/data/<app namespace>/files' 
> > > > > > directory
> > > > > > FileOutputStream fos = openFileOutput(fileName, 
> > > > > > Context.MODE_PRIVATE);
> > > > > > int read = 0;
> > > > > > byte[] buffer = new byte[512];
> > > > > > BufferedInputStream bis = new BufferedInputStream((InputStream) 
> > > > > > data);
> > > > > > do{
> > > > > >         read = bis.read(buffer);
> > > > > >         if(read > 0){
> > > > > >                 fos.write(buffer, 0, read);
> > > > > >         }
>
> > > > > > }while(read != -1);
>
> > > > > > and then i try to invoke an installation of the application by using
> > > > > > the following code (which I belive should bring the system UI up for
> > > > > > the user to confirm the install):
>
> > > > > > Intent intent = new Intent();
> > > > > > intent.setAction(android.content.Intent.ACTION_VIEW);
> > > > > > intent.setDataAndType(Uri.parse("/data/data/test.calle.helloworld/
> > > > > > files/AndroidHelloWorld.apk"), "application/vnd.android.package-
> > > > > > archive");
> > > > > > startActivity(intent);
>
> > > > > > but this only generates an ActivityNotFoundException:
> > > > > > 07-01 10:11:05.354: ERROR/AndroidRuntime(2480):
> > > > > > android.content.ActivityNotFoundException: No Activity found to 
> > > > > > handle
> > > > > > Intent { action=android.intent.action.VIEW data=/data/data/
> > > > > > test.calle.helloworld/files/AndroidHelloWorld.apk type=application/
> > > > > > vnd.android.package-archive }
>
> > > > > > B1. What am I doing wrong/missing in the attempt to install the
> > > > > > downloaded application?
>
> > > > > > B2. Will this approach bring the system UI up (for the user to 
> > > > > > confirm
>
> ...
>
> tamamını oku »- Alıntıyı gizle -
>
> - Alıntıyı göster -

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to