Thanks Mark.
 How exactly am i supposed to go about it? And just a small question.
When the person modifies it via the Settings application he will be
able to install the application. So when I try to install a 3rd party
app into the emulator via the command adb install <path of apk> , how
does it install correctly? Are the settings modified by the install
command?

Once again Thanks for the help.

On May 28, 8:23 am, Mark Murphy <[email protected]> wrote:
> chaitanya wrote:
> > Hi Guys,
> > I am trying to install a 3rd party free app through code. I initially
> > download the apk from the web-site (androidfreeware.org), store it on
> > a SD Card. I am using an emulator to check whether my app is working
> > properly or not. I have attached a SD card to the currently running
> > avd.
>
> >     Then when the user clicks on the Install, I use this code to
> > install it on the SD card.
>
> > public void onClick(View arg0) {
> >            // TODO Auto-generated method stub
> >            boolean success;
> >            int result = Settings.Secure.getInt(getContentResolver(),
> >                            Settings.Secure.INSTALL_NON_MARKET_APPS, 0);
> >            if (result == 0)
> >                    success = Settings.Secure.putString(getContentResolver(),
> >                                    Settings.Secure.INSTALL_NON_MARKET_APPS, 
> > "1");
> >            Intent intent = new Intent();
> >            intent.setAction(android.content.Intent.ACTION_VIEW);
> >            intent.setDataAndType(Uri.fromFile(downloadFile),
> >                            "application/vnd.android.package-archive");
> >            startActivity(intent);
> >    }
>
> You cannot modify Settings.Secure values from code. Please allow the
> user to change that setting via the Settings application.
>
> > I read somewhere that in order to install 3rd party apps we need to
> > set the value of INSTALL_NON_MARKET_APPS to 1. Do we need to set any
> > permission in the manifest file. Also, when I checked logcat I got the
> > following error
>
> >      Could not read the AndroidManifest.xml file of /sdcard/test.apk
> > and then it threw a FileNotFound Exception
>
> Note that you cannot have the SD card mounted both on your development
> machine and on the device at the same time. If you want to be able to
> access files on the SD card from code, you need to unmount the SD card
> from your development machine.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android Online Training: 21-25 June 2010:http://onlc.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en

Reply via email to