+ private AlertDialog createSelector(final boolean sendAction) {
+
+ int titleId;
+ if (sendAction) {
+ titleId = R.string.activity_chooser_send_file_title;
+ } else {
+ titleId = R.string.activity_chooser_title;
+ }
+
+ return new AlertDialog.Builder(getSherlockActivity())
+ .setTitle(titleId)
+ .setAdapter(mAdapter, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ // Add the information of the chosen activity to the intent to send
+ ResolveInfo chosen = mAdapter.getItem(which);
+ ActivityInfo actInfo = chosen.activityInfo;
+ ComponentName name=new ComponentName(actInfo.applicationInfo.packageName, actInfo.name);
+ mIntent.setComponent(name);
+
+ if (sendAction) {
+ dialog.dismiss(); // explicitly added for Android 2.x devices
+
+ // Send the file
+ ((FileActivity)getSherlockActivity()).startActivity(mIntent);
+
+ } else {
+ // Create a new share resource
+ FileOperationsHelper foh = new FileOperationsHelper();
+ foh.shareFileWithLinkToApp(mFile, mIntent, (FileActivity)getSherlockActivity());
+ }
+ }
+ })
+ .create();
+ }