/**@class android.widget.ActivityChooserModel @extends android.database.DataSetObservable <p> This class represents a data model for choosing a component for handing a given {@link Intent}. The model is responsible for querying the system for activities that can handle the given intent and order found activities based on historical data of previous choices. The historical data is stored in an application private file. If a client does not want to have persistent choice history the file can be omitted, thus the activities will be ordered based on historical usage for the current session. <p> </p> For each backing history file there is a singleton instance of this class. Thus, several clients that specify the same history file will share the same model. Note that if multiple clients are sharing the same model they should implement semantically equivalent functionality since setting the model intent will change the found activities and they may be inconsistent with the functionality of some of the clients. For example, choosing a share activity can be implemented by a single backing model and two different views for performing the selection. If however, one of the views is used for sharing but the other for importing, for example, then each view should be backed by a separate model. </p> <p> The way clients interact with this class is as follows: </p> <p> <pre> <code> // Get a model and set it to a couple of clients with semantically similar function. ActivityChooserModel dataModel = ActivityChooserModel.get(context, "task_specific_history_file_name.xml"); ActivityChooserModelClient modelClient1 = getActivityChooserModelClient1(); modelClient1.setActivityChooserModel(dataModel); ActivityChooserModelClient modelClient2 = getActivityChooserModelClient2(); modelClient2.setActivityChooserModel(dataModel); // Set an intent to choose a an activity for. dataModel.setIntent(intent); <pre> <code> </p> <p> <strong>Note:</strong> This class is thread safe. </p> @hide */ var ActivityChooserModel = { /** The default name of the choice history file. */ DEFAULT_HISTORY_FILE_NAME : "activity_choser_model_history.xml", /** The default maximal length of the choice history. */ DEFAULT_HISTORY_MAX_LENGTH : "50", /**Gets the data model backed by the contents of the provided file with historical data. Note that only one data model is backed by a given file, thus multiple calls with the same file name will return the same model instance. If no such instance is present it is created. <p> <strong>Note:</strong> To use the default historical data file clients should explicitly pass as file name {@link #DEFAULT_HISTORY_FILE_NAME}. If no persistence of the choice history is desired clients should pass <code>null</code> for the file name. In such case a new model is returned for each invocation. </p> <p> <strong>Always use difference historical data files for semantically different actions. For example, sharing is different from importing.</strong> </p> @param {Object {Context}} context Context for loading resources. @param {String} historyFileName File name with choice history, <code>null</code> if the model should not be backed by a file. In this case the activities will be ordered only by data from the current session. @return {Object {android.widget.ActivityChooserModel}} The model. */ get : function( ) {}, /**Sets an intent for which to choose a activity. <p> <strong>Note:</strong> Clients must set only semantically similar intents for each data model. <p> @param {Object {Intent}} intent The intent. */ setIntent : function( ) {}, /**Gets the intent for which a activity is being chosen. @return {Object {android.content.Intent}} The intent. */ getIntent : function( ) {}, /**Gets the number of activities that can handle the intent. @return {Number} The activity count. @see #setIntent(Intent) */ getActivityCount : function( ) {}, /**Gets an activity at a given index. @return {Object {android.content.pm.ResolveInfo}} The activity. @see ActivityResolveInfo @see #setIntent(Intent) */ getActivity : function( ) {}, /**Gets the index of a the given activity. @param {Object {ResolveInfo}} activity The activity index. @return {Number} The index if found, -1 otherwise. */ getActivityIndex : function( ) {}, /**Chooses a activity to handle the current intent. This will result in adding a historical record for that action and construct intent with its component name set such that it can be immediately started by the client. <p> <strong>Note:</strong> By calling this method the client guarantees that the returned intent will be started. This intent is returned to the client solely to let additional customization before the start. </p> @return {Object {android.content.Intent}} An {@link Intent} for launching the activity or null if the policy has consumed the intent or there is not current intent set via {@link #setIntent(Intent)}. @see HistoricalRecord @see OnChooseActivityListener */ chooseActivity : function( ) {}, /**Sets the listener for choosing an activity. @param {Object {ActivityChooserModel.OnChooseActivityListener}} listener The listener. */ setOnChooseActivityListener : function( ) {}, /**Gets the default activity, The default activity is defined as the one with highest rank i.e. the first one in the list of activities that can handle the intent. @return {Object {android.content.pm.ResolveInfo}} The default activity, <code>null</code> id not activities. @see #getActivity(int) */ getDefaultActivity : function( ) {}, /**Sets the default activity. The default activity is set by adding a historical record with weight high enough that this activity will become the highest ranked. Such a strategy guarantees that the default will eventually change if not used. Also the weight of the record for setting a default is inflated with a constant amount to guarantee that it will stay as default for awhile. @param {Number} index The index of the activity to set as default. */ setDefaultActivity : function( ) {}, /**Sets the sorter for ordering activities based on historical data and an intent. @param {Object {ActivityChooserModel.ActivitySorter}} activitySorter The sorter. @see ActivitySorter */ setActivitySorter : function( ) {}, /**Sets the maximal size of the historical data. Defaults to {@link #DEFAULT_HISTORY_MAX_LENGTH} <p> <strong>Note:</strong> Setting this property will immediately enforce the specified max history size by dropping enough old historical records to enforce the desired size. Thus, any records that exceed the history size will be discarded and irreversibly lost. </p> @param {Number} historyMaxSize The max history size. */ setHistoryMaxSize : function( ) {}, /**Gets the history max size. @return {Number} The history max size. */ getHistoryMaxSize : function( ) {}, /**Gets the history size. @return {Number} The history size. */ getHistorySize : function( ) {}, };