intent.action_send and intent chooser

by tnull » Tue, 20 Jul 2010 22:20:44 GMT


Sponsored Links
 When creating an intent with action send to send some data, is there a
way to filter the results that are included in the activity chooser
that is created using Intent.createChooser? I have not seen a way to
do this other than setting the mime type, but it is not flexible
enough.

For example, there is a situation when I want e-mail apps to be the
only results in the activity chooser dialog. Setting the type to "text/
html" successfully filters this down to email apps, except when
bluetooth is enabled. Bluetooth appears in the list as well, but this
is not desirable. Surely there is a way to have a little more control
over the results?

--



intent.action_send and intent chooser

by Mark Murphy » Tue, 20 Jul 2010 22:31:06 GMT


 


What are "e-mail apps"?


Only on your test environment(s). Anyone can create an application
that supports ACTION_SEND of text/html -- this it not something
exclusive to "e-mail apps". I would not be the least bit surprised if
there are others on certain devices or out on the Market.


Write your own chooser dialog, using PackageManager.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to Android Development_ Version 3.1 Available!

--


Sponsored Links


intent.action_send and intent chooser

by tnull » Tue, 20 Jul 2010 23:39:13 GMT


 With e-mail apps, I just meant I was looking to filter the results to
e-mail clients, not necessarily anything that can handle "text/html",
which I realized wouldn't work when bluetooth popped up.

Thank you for the tip on creating my own dialog using PackageManager,
I will look into that.







--



Other Threads

1. [WTA]game android spt Football manager

sesuai subject...

suhu2semua mao tanya ni

ada gk sih...game kaya football manager atau sejenisnya di android...

-- 
===============

2. Items Randomly Shift in ListView

I'm using a custom adapter which populates a ListView with a custom widget; 
the list shows bluetooth devices within range. I use a BroadcastReceiver to 
find the bluetooth devices and dynamically populate the list when I do. I 
call a function, addDevice(), from my custom adapter, which updates its 
internal list of devices and calls the notifyDataSetChanged().

However, my problem is that instead of listing the devices in the order of 
which it was added, it constantly shift the order of the items in the list, 
as new items are added (i.e. A bluetooth device will appear first in the 
list and then after notifyDataSetChanged() is called, it will appear 3rd, 
then maybe 6th, and back up to 4th in the list). Does anyone have any idea 
as to why this may be and how I might be able to fix it? Note the Adapter 
and BroadcastReciever are in different classes.


Custom Adapter (*DeviceAdpater.java*):

   public View getView(int position, View convertView, ViewGroup parent)
   {     
      CheckBoxItemView   itemView;

      // Check to see if the view is null and inflate it if so
      if (convertView == null)
      {     
         itemView = new CheckBoxItemView(app_context);
      
         // Bind the data to the new widget from the data from given list
         itemView.setName(device_list.get(position).getName());
         itemView.setText(device_list.get(position).getText());
         itemView.setIconImage(device_list.get(position).getIconImage());
      
         // Set the listener for the checkbox
         itemView.getCheckBox().setOnCheckedChangeListener(
            device_list.get(position));
         Log.i("DEBUG", "View is null---- " + itemView.getName());
      }
      else
      {
         itemView = (CheckBoxItemView) convertView;
      }
      
      return itemView;
   }
   
   public void addDevice(CheckBoxItemView device, String address)
   {
      // Add the new device and its bluetooth address to the lists
      device_list.add(device);
      address_list.add(address);

      // Tell the view to refresh itself
      notifyDataSetChanged();
   }


Main activity class:

   private void addBluetoothDevice(String deviceName, String address,
      boolean pairedWith)
   {
      CheckBoxItemView   itemRow;

      // Create a new checkbox item for the list of bluetooth devices; the
      // name of the widget component and its text will be the same as
      // the bluetooth device's name
      itemRow = new CheckBoxItemView(this);
      itemRow.setName(String.format("%s", deviceName));
      itemRow.setText(String.format("%s", deviceName));

      // Check to see if this device has already been paired with in a
      // previous session
      if (pairedWith == true)
      {
         itemRow.setIconImage(R.drawable.sample_0);
      }
      else
      {
         // Unknown bluetooth device so use the default image
         itemRow.setIconImage(R.drawable.sample_1);
      }

      // Add the new row featuring the bluetooth device to the adapter
      device_adapter.addDevice(itemRow, address);
   }

   private class ActivityReceiver extends BroadcastReceiver
   {
      public void onReceive(Context context, Intent intent)
      {
         String            action;
         BluetoothDevice   btDevice;

         // Get the intended action and process it
         action = intent.getAction();
         if (action.equals(BluetoothDevice.ACTION_FOUND))
         {
            // Get the bluetooth device that was found
            btDevice = 
intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

            // If the device hasn't been paired (which would mean that it's
            // already in list), go ahead and add it now
            if (btDevice.getBondState() != BluetoothDevice.BOND_BONDED)
            {
               addBluetoothDevice(btDevice.getName(), btDevice.getAddress(),
                  false);
            }
         }
      }
   }


Tracing through the steps, I also find that sometimes when a device is added 
and notifyDataSetChanged() is called, getView will not be called for that 
new device. I'm not sure if this may be related to the random list 
population or if it's a bluetooth hardware thing (the bluetooth in range are 
from other computers in my room and custom created hardware).

-- 

3. wbxml parser

4. Using Restlet on Android

5. Freezing When Using ActivityInstrumentationTestCase2

6. Detecting Package Update

7. Setup ADB with Elocity A7.