[android-developers] Re: How to get results from intent launched from preference screen?

2010-08-01 Thread Naveen
I found the answer, just updating here...

   // Intent preference
   DevicePref =
   getPreferenceManager().createPreferenceScreen(this);

   // Show a Screen with list of Devices Discovered

//   Intent i = new Intent(this,getDevice.class);
//   DevicePref.setIntent(i);
   DevicePref.setTitle(Select Device);
   DevicePref.setSummary(mSelectedDevice);
   deviceOptionsCat.addPreference(DevicePref);



On Aug 2, 1:34 pm, Naveen naveen...@gmail.com wrote:
 Hi!
 I need help in geting results back from intent launched from
 preference screen

        // Intent preference
        DevicePref =
 getPreferenceManager().createPreferenceScreen(this);

        // Show a Screen with list of Devices Discovered
        Intent i = new Intent(this,getDevice.class);
        DevicePref.setIntent(i);
        DevicePref.setTitle(Select Device);
        DevicePref.setSummary(mSelectedDevice);
        deviceOptionsCat.addPreference(DevicePref);

 I want user to select device... In preference screeen I show Select
 Device .. when user clicks that, another screen is launched by intent
 where all devices are listed. User selects the device.

 Now how do I know user selected which device? And I want to update
 that in the summary.

 Pls. let me know
 Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to get results from intent launched from preference screen?

2010-08-01 Thread Naveen
I got the answer, Hope it will help someone like me...

Do not mention intent while creating preference like I did in above
code.. Mention intent on OnPreferenceClickListener and then do
StartActivityForResult()


// Intent preference
   DevicePref =
getPreferenceManager().createPreferenceScreen(this);
   // Show a Screen with list of Devices Discovered

   DevicePref.setOnPreferenceClickListener(onPreferenceClick);

   DevicePref.setTitle(Select Device);
   DevicePref.setSummary(mSelectedDevice);
   deviceOptionsCat.addPreference(DevicePref);




   OnPreferenceClickListener onPreferenceClick = new
Preference.OnPreferenceClickListener() {
   public boolean onPreferenceClick(Preference preference) {

   if (preference ==DevicePref )
   {
   Intent i = new
Intent(DevuiceOptions.this,ListDevices.class);
   DevicePref.setIntent(i);
   startActivityForResult(i,CHOOSE_DEVICE);

   }
   return true;
   }
   };



 @Override
   protected void onActivityResult(int requestCode, int resultCode,
Intent data)
   {

   switch (requestCode) {

   case Constants.CHOOSE_DEVICE:
   {
   if (data!=null )
   {
   Bundle b = data.getExtras();
   mSelectedDevice =(String) b.get(Name);
   UpdatePreferences();
   }

   }
}
}


Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en