Example usage for android.support.v4.app FragmentActivity getSupportFragmentManager

List of usage examples for android.support.v4.app FragmentActivity getSupportFragmentManager

Introduction

In this page you can find the example usage for android.support.v4.app FragmentActivity getSupportFragmentManager.

Prototype

public FragmentManager getSupportFragmentManager() 

Source Link

Document

Return the FragmentManager for interacting with fragments associated with this activity.

Usage

From source file:im.neon.activity.CommonActivityUtils.java

/**
 * Display the unknown e2e devices/*  w w  w.  ja v  a2 s. c  om*/
 * @param session the session
 * @param activity the calling activity
 * @param unknownDevices the unknown devices list
 * @param listener optional listener to add an optional "Send anyway" button
 */
public static void displayUnknownDevicesDialog(MXSession session, FragmentActivity activity,
        MXUsersDevicesMap<MXDeviceInfo> unknownDevices,
        VectorUnknownDevicesFragment.IUnknownDevicesSendAnywayListener listener) {
    // sanity checks
    if ((null == unknownDevices) || (0 == unknownDevices.getMap().size())) {
        return;
    }

    FragmentManager fm = activity.getSupportFragmentManager();

    VectorUnknownDevicesFragment fragment = (VectorUnknownDevicesFragment) fm
            .findFragmentByTag(TAG_FRAGMENT_UNKNOWN_DEVICES_DIALOG_DIALOG);
    if (fragment != null) {
        fragment.dismissAllowingStateLoss();
    }

    fragment = VectorUnknownDevicesFragment.newInstance(session.getMyUserId(), unknownDevices, listener);
    fragment.show(fm, TAG_FRAGMENT_UNKNOWN_DEVICES_DIALOG_DIALOG);
}

From source file:io.amira.zen.core.ZenFragmentManager.java

public void load(String title, boolean loadView) {

    //FragmentActivity activity = ZenAppManager.getActivity();
    FragmentActivity activity = ZenApplication.getAppActivity();

    ZenApplication.log("SETZENFRAGMENT " + title + " - " + activity.getClass().getCanonicalName());

    ZenApplication.log("your api version is ok :  GRAZIE A STO CAZZO.");
    /*/*w ww .  ja v a  2 s  .c om*/
     * API LEVEL GREATER OR EQUAL TO HONEYCOMB.
     */

    ZenApplication.log("AVAILABLEFRAGMENTS ARE: " + availableFragments);
    if (availableFragments.containsKey(title)) {
        /*
         * IF WE HAVE ALREADY CREATED AN ATLFRAGMENT,
         * THEN IT'S INSIDE AVAILABLEFRAGMENTS.
         */
        try {
            long p = System.nanoTime();
            ZenApplication.log("Fragment " + title + " instance available, using it.");
            int content_frame_id = ZenResManager.getResourceId("content_frame");

            FragmentManager fragmentManager = activity.getSupportFragmentManager();

            //ZenNavigationManager.push(availableFragments.get(title));
            ZenApplication.navigation().push(title,
                    availableFragments.get(title).getClass().getSuperclass().getCanonicalName());
            lastFragment = title;
            //TEST

            FragmentTransaction transaction = fragmentManager.beginTransaction();
            //ANIMATIONS

            if (ZenApplication.navigation().isBack()) {
                transaction.setCustomAnimations(ZenResManager.getAnimId("back_enter"),
                        ZenResManager.getAnimId("back_exit"));
                //transaction.setCustomAnimations(ZenResManager.getAnimId("back_enter"), ZenResManager.getAnimId("back_exit"), ZenResManager.getAnimId("back_pop_enter") , ZenResManager.getAnimId("back_pop_exit"));

            } else {
                transaction.setCustomAnimations(ZenResManager.getAnimId("enter"),
                        ZenResManager.getAnimId("exit"));
                //transaction.setCustomAnimations(ZenResManager.getAnimId("enter"), ZenResManager.getAnimId("exit"), ZenResManager.getAnimId("pop_enter") , ZenResManager.getAnimId("pop_exit"));
            }

            transaction.replace(content_frame_id, (Fragment) availableFragments.get(title))
                    .commitAllowingStateLoss();
            long d = System.nanoTime();
            //ZenAppManager.moveDrawer(true);
            ZenApplication.log("TIME to recover old " + (d - p));

        } catch (NullPointerException e) {
            e.printStackTrace();
        }
    } else {
        /*
         * CREATE A NEW FRAGMENT
         *
         * THERE MUST BE A CLASS NAMED:
         *
         * titleController.java
         *
         * WHICH EXTENDS ATLFragment
         * if such class is not available,
         * ClassNotFoundException is launched.
         *
         */
        try {
            ZenApplication.log("create new fragment");
            long p = System.nanoTime();

            String layoutName;
            String toCallClass;
            Integer layoutId;

            ZenApplication.log("TIT: " + title);

            //layoutName = ZenAppManager.getLayouts().get(title);
            layoutName = ZenApplication.config().getDrawer_menu_layouts().get(title);
            // if layoutName is null fall back to title (because is the layout actually)
            if (layoutName == null) {
                ZenApplication.log("ZENFRAGMAN: title is null");
                layoutName = title;
            }
            ZenApplication.log("LAY NAME: " + layoutName);

            //boolean isDetail = ZenAppManager.getDetailLayouts().containsKey(layoutName);
            //ZenApplication.log("ISDETAIL: "+isDetail);

            String[] tlist;
            tlist = layoutName.split("_");
            ZenApplication.log(tlist.length);

            String cName = layoutName;
            if (tlist.length > 1) {
                StringBuilder sBuilder = new StringBuilder();
                sBuilder.append(tlist[0]);
                for (int i = 1; i < tlist.length; i++) {
                    String t = Character.toUpperCase(tlist[i].charAt(0)) + tlist[i].substring(1);
                    //tlist[i] = t;
                    sBuilder.append(t);
                }
                cName = sBuilder.toString();
            }
            //else {
            //    cName = layoutName;
            //}
            ZenApplication.log("CNAME: " + cName);

            //if (!isDetail) {
            //toCallClass = ZenAppManager.getLayouts().get(title);
            toCallClass = cName;
            //layoutId = ZenAppManager.getLayouts().get(title);
            layoutId = ZenResManager.getLayoutId(layoutName);
            ZenApplication.log("SET NOT DETAIL LAYOUTID " + layoutId);
            //}
            /*
            else {
                //toCallClass = ZenAppManager.getDetailLayouts().get(title);
                //toCallClass = title + "Detail";
                toCallClass = cName + "Detail";
                ZenApplication.log("LAYOUTCLASS " + toCallClass);
                layoutId    = ZenResManager.getLayoutId(ZenAppManager.getDetailLayouts().get(layoutName));
                ZenApplication.log("SET DETAIL LAYOUTID " + layoutId);
            }*/

            //ZenApplication.log("LAYOUTID " + layoutId);

            //TENTATIVO
            //int pos = ZenAppManager.getLayouts().get(title); //prima non esisteva.
            //TENTATIVO

            toCallClass = Character.toUpperCase(toCallClass.charAt(0)) + toCallClass.substring(1);
            Class toCall = Class.forName("app.Controllers." + toCallClass + "Controller");
            ZenApplication.log("app.Controllers." + toCallClass + "Controller");
            try {

                availableFragments.put(title, toCall.newInstance());
                lastFragment = title;
                Object controller = availableFragments.get(title);

                String superclass = "io.amira.zen.layout.drawer.ZenFragment";
                if (ZenFragment.class.isAssignableFrom(controller.getClass())) {
                    //if (controller.getClass().getSuperclass().getCanonicalName().equals(superclass)) {
                    //
                    // QUESTO VUOL DIRE CHE ABBIAMO CARICATO UNA CLASSE CHE HA COME SUPERCLASSE ATLFRAGMENT
                    //
                    Class[] paramTypes = new Class[2]; //prima era new class[2]
                    paramTypes[0] = String.class;
                    paramTypes[1] = Integer.class;

                    //paramTypes[3]       = DrawerLayout.class;
                    //paramTypes[4]       = ListView.class;

                    //TENTATIVO
                    //Integer layoutId = ZenAppManager.getLayoutIds()[pos]; // prima era position
                    //= ZenAppManager.getLayouts().get(title);
                    //TENTATIVO
                    ZenApplication.log("TRYING LAYOUTID " + layoutId);

                    toCall.getMethod("setVariables", paramTypes).invoke(controller,
                            createParameters(title, layoutId));

                    int content_frame_id = ZenResManager.getResourceId("content_frame");
                    FragmentManager fragmentManager = activity.getSupportFragmentManager();

                    //TEST
                    //ZenNavigationManager.push(controller);
                    ZenApplication.navigation().push(title,
                            controller.getClass().getSuperclass().getCanonicalName());
                    //TEST

                    if (loadView) {

                        FragmentTransaction transaction = fragmentManager.beginTransaction();
                        //ANIMATION

                        if (ZenApplication.navigation().isBack()) {

                            transaction.setCustomAnimations(ZenResManager.getAnimId("back_enter"),
                                    ZenResManager.getAnimId("back_exit"));
                            //transaction.setCustomAnimations(ZenResManager.getAnimId("back_enter"), ZenResManager.getAnimId("back_exit"), ZenResManager.getAnimId("back_pop_enter") , ZenResManager.getAnimId("back_pop_exit"));

                        } else {
                            transaction.setCustomAnimations(ZenResManager.getAnimId("enter"),
                                    ZenResManager.getAnimId("exit"));

                            //transaction.setCustomAnimations(ZenResManager.getAnimId("enter"), ZenResManager.getAnimId("exit"), ZenResManager.getAnimId("pop_enter") , ZenResManager.getAnimId("pop_exit"));
                        }

                        transaction.replace(content_frame_id, (Fragment) controller).commitAllowingStateLoss();

                    }
                    ZenApplication.log("SAVING " + title + " - " + controller.getClass().getCanonicalName());

                    long d = System.nanoTime();
                    ZenApplication.log("TIME to create new fragment " + (d - p));

                }
            }

            catch (InstantiationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (NoSuchMethodException e) {

                e.printStackTrace();
            } catch (InvocationTargetException e) {

                e.printStackTrace();
            } catch (NullPointerException e) {
                e.printStackTrace();
            }
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        //ATLFragment atlf = new ATLFragment();
        //atlf.setCurrentActivity(activity);
        //Bundle args = new Bundle();

        //args.putString("title", title);

        //atlf.setArguments(args);

        //int content_frame_id = getResourceId("content_frame");
        //FragmentManager fragmentManager = activity.getFragmentManager();
        //fragmentManager.beginTransaction()
        //               .replace(content_frame_id, atlf)
        //               .commit();
        /*
         * PUSHING NEW FRAGMENT INSIDE LIST
         */

    }

    /*
     * FINALLY WE CLOSE THE DRAWER.
     */
    //ATLAppManager.closeDrawer();
}

From source file:android.support.v17.leanback.app.BackgroundManager.java

private void createSupportFragment(FragmentActivity activity) {
    // Use a fragment to ensure the background manager gets detached properly.
    BackgroundSupportFragment fragment = (BackgroundSupportFragment) activity.getSupportFragmentManager()
            .findFragmentByTag(FRAGMENT_TAG);
    if (fragment == null) {
        fragment = new BackgroundSupportFragment();
        activity.getSupportFragmentManager().beginTransaction().add(fragment, FRAGMENT_TAG).commit();
    } else {//from  w w w.  ja va  2 s . c o  m
        if (fragment.getBackgroundManager() != null) {
            throw new IllegalStateException("Created duplicated BackgroundManager for same "
                    + "activity, please use getInstance() instead");
        }
    }
    fragment.setBackgroundManager(this);
    mFragmentState = fragment;
}

From source file:HeaderGridView.java

/** added by Ahmed Basyouni
* this method take supported fragment and fragment activity to add that
* fragment as a banner to listView it create a layout at runtime then when
* view is added to list we replace it with fragment otherwise it will crash
* since view is not on screen to be replaced
* 
* @param fragment// ww  w.j a  v  a  2 s .c  o m
* @param activity
*/
public void addBannerFragment(final Fragment fragment, final FragmentActivity activity) {

    RelativeLayout layout = new RelativeLayout(activity);

    AbsListView.LayoutParams param = new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);

    layout.setLayoutParams(param);

    // please don't ever remove that view otherwise application will crash and I mean it :D
    View view = new View(activity);

    view.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, 300));

    view.setVisibility(View.INVISIBLE);

    layout.addView(view);

    layout.setId(CONTAINER_ID);

    addHeaderView(layout);

    this.addOnLayoutChangeListener(new OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
                int oldRight, int oldBottom) {

            HeaderGridView.this.removeOnLayoutChangeListener(this);

            FragmentManager manager = activity.getSupportFragmentManager();
            FragmentTransaction transaction = manager.beginTransaction();

            transaction.replace(CONTAINER_ID, fragment).commit();
        }
    });

}

From source file:org.catrobat.catroid.utils.DownloadUtil.java

public void prepareMediaDownloadAndStartIfPossible(FragmentActivity activity, String url, String mediaType,
        String mediaName, String filePath, String callingActivity) {
    if (mediaName == null) {
        return;/*  ww  w .j  a va  2 s.co  m*/
    }

    boolean mediaNameExists;
    if (callingActivity.contains(LookFragment.TAG) || callingActivity.contains(SoundFragment.TAG)) {
        switch (mediaType) {
        case Constants.MEDIA_TYPE_LOOK:
            mediaNameExists = Utils.checkIfLookExists(mediaName);
            break;
        case Constants.MEDIA_TYPE_SOUND:
            mediaNameExists = Utils.checkIfSoundExists(mediaName);
            break;
        default:
            mediaNameExists = false;
        }
    } else {
        mediaNameExists = false;
    }

    webViewActivity = (WebViewActivity) activity;

    if (mediaNameExists) {
        OverwriteRenameMediaDialog renameMediaDialog = new OverwriteRenameMediaDialog();

        renameMediaDialog.setContext(activity);
        renameMediaDialog.setMediaName(mediaName);
        renameMediaDialog.setMediaType(mediaType);
        renameMediaDialog.setURL(url);
        renameMediaDialog.setFilePath(filePath);
        renameMediaDialog.setCallingActivity(callingActivity);
        renameMediaDialog.setWebViewActivity(webViewActivity);

        renameMediaDialog.show(activity.getSupportFragmentManager(),
                OverwriteRenameMediaDialog.DIALOG_FRAGMENT_TAG);
    } else {
        startMediaDownload(activity, url, mediaName, filePath);
    }
}

From source file:com.fastbootmobile.encore.utils.Utils.java

public static void showSongOverflow(final FragmentActivity context, final View parent, final Song song,
        final boolean hideArtist) {
    PopupMenu popupMenu = new PopupMenu(context, parent);
    popupMenu.inflate(R.menu.track_overflow);

    if (song.getArtist() == null || hideArtist) {
        // This song has no artist information, hide the entry
        Menu menu = popupMenu.getMenu();
        menu.removeItem(R.id.menu_open_artist);
    }//w w w  . ja  v  a 2  s .  com

    if (song.getAlbum() == null) {
        // This song has no album information, hide the entry
        Menu menu = popupMenu.getMenu();
        menu.removeItem(R.id.menu_add_album_to_queue);
    }

    popupMenu.show();

    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            final ProviderAggregator aggregator = ProviderAggregator.getDefault();

            switch (menuItem.getItemId()) {
            case R.id.menu_play_now:
                PlaybackProxy.playSong(song);
                break;

            case R.id.menu_play_next:
                PlaybackProxy.playNext(song);
                break;

            case R.id.menu_open_artist:
                Intent intent = ArtistActivity.craftIntent(context, null, song.getArtist(), song.getProvider(),
                        context.getResources().getColor(R.color.default_album_art_background));
                context.startActivity(intent);
                break;

            case R.id.menu_add_to_queue:
                PlaybackProxy.queueSong(song, false);
                Toast.makeText(context, R.string.toast_song_added_to_queue, Toast.LENGTH_SHORT).show();
                break;

            case R.id.menu_add_album_to_queue:
                PlaybackProxy.queueAlbum(aggregator.retrieveAlbum(song.getAlbum(), song.getProvider()), false);
                Toast.makeText(context, R.string.toast_album_added_to_queue, Toast.LENGTH_SHORT).show();
                break;

            case R.id.menu_add_to_playlist:
                PlaylistChooserFragment fragment = PlaylistChooserFragment.newInstance(song);
                fragment.show(context.getSupportFragmentManager(), song.getRef());
                break;

            default:
                return false;
            }
            return true;
        }
    });
}

From source file:org.sufficientlysecure.keychain.ui.EncryptFilesFragment.java

@Override
public void onQueuedOperationSuccess(final SignEncryptResult result) {
    super.onQueuedOperationSuccess(result);

    hideKeyboard();//  www.j  a  v a 2  s.  c  om

    // protected by Queueing*Fragment
    FragmentActivity activity = getActivity();

    if (mDeleteAfterEncrypt) {
        // TODO make behavior coherent here
        DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment
                .newInstance(mFilesAdapter.getAsArrayList());
        deleteFileDialog.setOnDeletedListener(new DeleteFileDialogFragment.OnDeletedListener() {

            @Override
            public void onDeleted() {
                if (mAfterEncryptAction == AfterEncryptAction.SHARE) {
                    // Share encrypted message/file
                    startActivity(
                            Intent.createChooser(createSendIntent(), getString(R.string.title_share_file)));
                } else {
                    Activity activity = getActivity();
                    if (activity == null) {
                        // it's gone, there's nothing we can do here
                        return;
                    }
                    // Save encrypted file
                    result.createNotify(activity).show();
                }
            }

        });
        deleteFileDialog.show(activity.getSupportFragmentManager(), "deleteDialog");
    } else {

        switch (mAfterEncryptAction) {

        case SHARE:
            // Share encrypted message/file
            startActivity(Intent.createChooser(createSendIntent(), getString(R.string.title_share_file)));
            break;

        case COPY:

            ClipboardManager clipMan = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
            if (clipMan == null) {
                Notify.create(activity, R.string.error_clipboard_copy, Style.ERROR).show();
                break;
            }
            ClipData clip = new ClipData(getString(R.string.label_clip_title),
                    // make available as application/pgp-encrypted
                    new String[] { "text/plain" }, new ClipData.Item(mOutputUris.get(0)));
            clipMan.setPrimaryClip(clip);
            result.createNotify(activity).show();
            break;

        case SAVE:
            // Encrypted file was saved already, just show notification
            result.createNotify(activity).show();
            break;
        }
    }

}

From source file:com.oceansky.yellow.utils.Utils.java

public static void showSongOverflow(final FragmentActivity context, final View parent, final Song song,
        final boolean hideArtist) {
    if (song == null) {
        return;//from w  w  w .  j  ava  2 s .c  om
    }

    PopupMenu popupMenu = new PopupMenu(context, parent);
    popupMenu.inflate(R.menu.track_overflow);

    if (song.getArtist() == null || hideArtist) {
        // This song has no artist information, hide the entry
        Menu menu = popupMenu.getMenu();
        menu.removeItem(R.id.menu_open_artist);
    }

    if (song.getAlbum() == null) {
        // This song has no album information, hide the entry
        Menu menu = popupMenu.getMenu();
        menu.removeItem(R.id.menu_add_album_to_queue);
    }

    popupMenu.show();

    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            final ProviderAggregator aggregator = ProviderAggregator.getDefault();

            switch (menuItem.getItemId()) {
            case R.id.menu_play_now:
                PlaybackProxy.playSong(song);
                break;

            case R.id.menu_play_next:
                PlaybackProxy.playNext(song);
                break;

            case R.id.menu_open_artist:
                Intent intent = ArtistActivity.craftIntent(context, null, song.getArtist(), song.getProvider(),
                        context.getResources().getColor(R.color.default_album_art_background));
                context.startActivity(intent);
                break;

            case R.id.menu_add_to_queue:
                PlaybackProxy.queueSong(song, false);
                Toast.makeText(context, R.string.toast_song_added_to_queue, Toast.LENGTH_SHORT).show();
                break;

            case R.id.menu_add_album_to_queue:
                PlaybackProxy.queueAlbum(aggregator.retrieveAlbum(song.getAlbum(), song.getProvider()), false);
                Toast.makeText(context, R.string.toast_album_added_to_queue, Toast.LENGTH_SHORT).show();
                break;

            case R.id.menu_add_to_playlist:
                PlaylistChooserFragment fragment = PlaylistChooserFragment.newInstance(song);
                fragment.show(context.getSupportFragmentManager(), song.getRef());
                break;

            default:
                return false;
            }
            return true;
        }
    });
}

From source file:org.mariotaku.twidere.util.Utils.java

public static void openImage(final Context context, final Uri uri, final boolean is_possibly_sensitive) {
    if (context == null || uri == null)
        return;//from   w  ww . ja v  a  2s  . c o m
    final Intent intent = new Intent(INTENT_ACTION_VIEW_IMAGE);
    intent.setDataAndType(uri, "image/*");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
        intent.setClass(context, ImageViewerGLActivity.class);
    } else {
        intent.setClass(context, ImageViewerActivity.class);
    }
    final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    if (context instanceof FragmentActivity && is_possibly_sensitive
            && !prefs.getBoolean(PREFERENCE_KEY_DISPLAY_SENSITIVE_CONTENTS, false)) {
        final FragmentActivity activity = (FragmentActivity) context;
        final FragmentManager fm = activity.getSupportFragmentManager();
        final DialogFragment fragment = new SensitiveContentWaringDialogFragment();
        final Bundle args = new Bundle();
        args.putParcelable(INTENT_KEY_URI, uri);
        fragment.setArguments(args);
        fragment.show(fm, "sensitive_content_warning");
    } else {
        context.startActivity(intent);
    }
}

From source file:org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment.java

/**
 * Creates dialog/* w ww  . ja v  a 2  s. com*/
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();

    final String deleteFile = getArguments().getString(ARG_DELETE_FILE);

    AlertDialog.Builder alert = new AlertDialog.Builder(activity);

    alert.setIcon(R.drawable.ic_dialog_alert_holo_light);
    alert.setTitle(R.string.warning);
    alert.setMessage(this.getString(R.string.file_delete_confirmation, deleteFile));

    alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();

            // Send all information needed to service to edit key in other thread
            Intent intent = new Intent(activity, ApgIntentService.class);

            // fill values for this action
            Bundle data = new Bundle();

            intent.setAction(ApgIntentService.ACTION_DELETE_FILE_SECURELY);
            data.putString(ApgIntentService.DELETE_FILE, deleteFile);
            intent.putExtra(ApgIntentService.EXTRA_DATA, data);

            ProgressDialogFragment deletingDialog = ProgressDialogFragment.newInstance(
                    getString(R.string.progress_deleting_securely), ProgressDialog.STYLE_HORIZONTAL, false,
                    null);

            // Message is received after deleting is done in ApgService
            ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(activity, deletingDialog) {
                public void handleMessage(Message message) {
                    // handle messages by standard ApgHandler first
                    super.handleMessage(message);

                    if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
                        Toast.makeText(activity, R.string.file_delete_successful, Toast.LENGTH_SHORT).show();
                    }
                }
            };

            // Create a new Messenger for the communication back
            Messenger messenger = new Messenger(saveHandler);
            intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);

            // show progress dialog
            deletingDialog.show(activity.getSupportFragmentManager(), "deletingDialog");

            // start service with intent
            activity.startService(intent);
        }
    });
    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dismiss();
        }
    });
    alert.setCancelable(true);

    return alert.create();
}