Example usage for android.app Activity sendBroadcast

List of usage examples for android.app Activity sendBroadcast

Introduction

In this page you can find the example usage for android.app Activity sendBroadcast.

Prototype

@Override
    public void sendBroadcast(Intent intent) 

Source Link

Usage

From source file:org.ado.minesync.gui.fragment.DropboxFragment.java

private void notifyDropboxAccountUnlinked(Activity fragmentActivity) {
    Intent dropboxAccountIntent = new Intent(INTENT_DROPBOX_ACCOUNT);
    dropboxAccountIntent.putExtra(INTENT_PARAMETER_ACCOUNT_STATUS, INTENT_PARAMETER_VALUE_UNLINKED);
    fragmentActivity.sendBroadcast(dropboxAccountIntent);
}

From source file:hku.fyp14017.blencode.ui.controller.LookController.java

private void deleteLook(int position, ArrayList<LookData> lookDataList, Activity activity) {
    StorageHandler.getInstance().deleteFile(lookDataList.get(position).getAbsolutePath());

    lookDataList.remove(position);//from w w w.  j av a  2 s  .c o  m
    ProjectManager.getInstance().getCurrentSprite().setLookDataList(lookDataList);

    activity.sendBroadcast(new Intent(ScriptActivity.ACTION_LOOK_DELETED));
}

From source file:hku.fyp14017.blencode.ui.controller.SoundController.java

private void deleteSound(int position, ArrayList<SoundInfo> soundInfoList, Activity activity) {
    StorageHandler.getInstance().deleteFile(soundInfoList.get(position).getAbsolutePath());
    soundInfoList.remove(position);/* ww  w.j  a va 2 s.c o  m*/
    ProjectManager.getInstance().getCurrentSprite().setSoundList(soundInfoList);
    activity.sendBroadcast(new Intent(ScriptActivity.ACTION_SOUND_DELETED));
}

From source file:com.lee.sdk.utils.Utils.java

/**
 * ????//from   www  .  jav a 2s . c om
 * 
 * @param activity ?Activity???
 * @param nameId ????
 * @param iconId ??
 * @param appendFlags ????IntentFlag
 */
public static void addShortcut(Activity activity, int nameId, int iconId, int appendFlags) {
    Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");

    // ????
    shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, activity.getString(nameId));
    shortcut.putExtra("duplicate", false); // ????

    // ?Activity???
    ComponentName comp = new ComponentName(activity.getPackageName(), activity.getClass().getName());
    Intent intent = new Intent(Intent.ACTION_MAIN).setComponent(comp);
    if (appendFlags != 0) {
        intent.addFlags(appendFlags);
    }
    shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);

    // ??
    ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(activity, iconId);
    shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);

    activity.sendBroadcast(shortcut);
}

From source file:com.android.browser.BookmarksPageCallbacks.java

public boolean handleContextItem(int itemId, int groupPosition, int childPosition) {
    final Activity activity = getActivity();
    BrowserBookmarksAdapter adapter = getChildAdapter(groupPosition);

    switch (itemId) {
    case R.id.open_context_menu_id:
        loadUrl(adapter, childPosition);
        break;/*from   ww w .  ja va2s  .  c o  m*/
    case R.id.edit_context_menu_id:
        editBookmark(adapter, childPosition);
        break;
    case R.id.shortcut_context_menu_id:
        Cursor c = adapter.getItem(childPosition);
        activity.sendBroadcast(createShortcutIntent(getActivity(), c));
        break;
    case R.id.delete_context_menu_id:
        displayRemoveBookmarkDialog(adapter, childPosition);
        break;
    case R.id.new_window_context_menu_id:
        openInNewWindow(adapter, childPosition);
        break;
    case R.id.share_link_context_menu_id: {
        Cursor cursor = adapter.getItem(childPosition);
        Controller.sharePage(activity, cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE),
                cursor.getString(BookmarksLoader.COLUMN_INDEX_URL),
                getBitmap(cursor, BookmarksLoader.COLUMN_INDEX_FAVICON),
                getBitmap(cursor, BookmarksLoader.COLUMN_INDEX_THUMBNAIL));
        break;
    }
    case R.id.copy_url_context_menu_id:
        copy(getUrl(adapter, childPosition));
        break;
    case R.id.homepage_context_menu_id: {
        BrowserSettings.getInstance().setHomePage(getUrl(adapter, childPosition));
        Toast.makeText(activity, R.string.homepage_set, Toast.LENGTH_LONG).show();
        break;
    }
    // Only for the Most visited page
    case R.id.save_to_bookmarks_menu_id: {
        Cursor cursor = adapter.getItem(childPosition);
        String name = cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE);
        String url = cursor.getString(BookmarksLoader.COLUMN_INDEX_URL);
        // If the site is bookmarked, the item becomes remove from
        // bookmarks.
        Bookmarks.removeFromBookmarks(activity, activity.getContentResolver(), url, name);
        break;
    }
    default:
        return false;
    }
    return true;
}

From source file:com.borqs.browser.BookmarksPageCallbacks.java

public boolean handleContextItem(int itemId, int groupPosition, int childPosition) {
    final Activity activity = getActivity();
    BrowserBookmarksAdapter adapter = getChildAdapter(groupPosition);

    switch (itemId) {
    case R.id.open_context_menu_id:
        loadUrl(adapter, childPosition);
        break;//from  w  ww .  j av a  2  s. c  o m
    case R.id.edit_context_menu_id:
        editBookmark(adapter, childPosition);
        break;
    case R.id.shortcut_context_menu_id:
        Cursor c = adapter.getItem(childPosition);
        activity.sendBroadcast(createShortcutIntent(getActivity(), c));
        break;
    case R.id.delete_context_menu_id:
        displayRemoveBookmarkDialog(adapter, childPosition);
        break;
    case R.id.new_window_context_menu_id:
        openInNewWindow(adapter, childPosition);
        break;
    case R.id.share_link_context_menu_id: {
        /*
         Cursor cursor = adapter.getItem(childPosition);
         Controller.sharePage(activity,
            cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE),
            cursor.getString(BookmarksLoader.COLUMN_INDEX_URL),
            getBitmap(cursor, BookmarksLoader.COLUMN_INDEX_FAVICON),
            getBitmap(cursor, BookmarksLoader.COLUMN_INDEX_THUMBNAIL));
            */
        break;
    }
    case R.id.copy_url_context_menu_id:
        copy(getUrl(adapter, childPosition));
        break;
    case R.id.homepage_context_menu_id: {
        // BrowserSettings.getInstance().setHomePage(getUrl(adapter, childPosition));
        Toast.makeText(activity, R.string.homepage_set, Toast.LENGTH_LONG).show();
        break;
    }
    // Only for the Most visited page
    case R.id.save_to_bookmarks_menu_id: {
        Cursor cursor = adapter.getItem(childPosition);
        String name = cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE);
        String url = cursor.getString(BookmarksLoader.COLUMN_INDEX_URL);
        // If the site is bookmarked, the item becomes remove from
        // bookmarks.
        Bookmarks.removeFromBookmarks(activity, activity.getContentResolver(), url, name);
        break;
    }
    default:
        return false;
    }
    return true;
}

From source file:com.borqs.browser.combo.BookmarksPageCallbacks.java

public boolean handleContextItem(int itemId, int groupPosition, int childPosition) {
    final Activity activity = this;
    BrowserBookmarksAdapter adapter = getChildAdapter(groupPosition);

    switch (itemId) {
    case R.id.open_context_menu_id:
        loadUrl(adapter, childPosition);
        break;/*from  ww w.j  a  v a2s  . c o  m*/
    case R.id.edit_context_menu_id:
        editBookmark(adapter, childPosition);
        break;
    case R.id.shortcut_context_menu_id:
        Cursor c = adapter.getItem(childPosition);
        activity.sendBroadcast(createShortcutIntent(this, c));
        break;
    case R.id.delete_context_menu_id:
        displayRemoveBookmarkDialog(adapter, childPosition);
        break;
    case R.id.new_window_context_menu_id:
        openInNewWindow(adapter, childPosition);
        break;
    case R.id.share_link_context_menu_id: {
        /*
         Cursor cursor = adapter.getItem(childPosition);
         Controller.sharePage(activity,
            cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE),
            cursor.getString(BookmarksLoader.COLUMN_INDEX_URL),
            getBitmap(cursor, BookmarksLoader.COLUMN_INDEX_FAVICON),
            getBitmap(cursor, BookmarksLoader.COLUMN_INDEX_THUMBNAIL));
            */
        break;
    }
    case R.id.copy_url_context_menu_id:
        copy(getUrl(adapter, childPosition));
        break;
    case R.id.homepage_context_menu_id: {
        // BrowserSettings.getInstance().setHomePage(getUrl(adapter, childPosition));
        Toast.makeText(activity, R.string.homepage_set, Toast.LENGTH_LONG).show();
        break;
    }
    // Only for the Most visited page
    case R.id.save_to_bookmarks_menu_id: {
        Cursor cursor = adapter.getItem(childPosition);
        String name = cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE);
        String url = cursor.getString(BookmarksLoader.COLUMN_INDEX_URL);
        // If the site is bookmarked, the item becomes remove from
        // bookmarks.
        Bookmarks.removeFromBookmarks(activity, activity.getContentResolver(), url, name);
        break;
    }
    default:
        return false;
    }
    return true;
}

From source file:org.catrobat.catroid.ui.controller.LookController.java

public void copyLook(int position, ArrayList<LookData> lookDataList, final Activity activity,
        LookFragment fragment) {/*from   w  w w  . j  a v  a 2s. co m*/
    LookData lookData = lookDataList.get(position);

    try {
        String projectName = ProjectManager.getInstance().getCurrentProject().getName();

        StorageHandler.getInstance().copyImage(projectName, lookData.getAbsolutePath(), null);

        String imageName = lookData.getLookName() + "_" + activity.getString(R.string.copy_addition);
        String imageFileName = lookData.getLookFileName();

        updateLookAdapter(imageName, imageFileName, lookDataList, fragment);
    } catch (IOException ioException) {
        Utils.showErrorDialog(activity, R.string.error_load_image);
        Log.e(TAG, Log.getStackTraceString(ioException));
    }
    activity.sendBroadcast(new Intent(ScriptActivity.ACTION_BRICK_LIST_CHANGED));
}

From source file:hku.fyp14017.blencode.ui.controller.LookController.java

public void copyLook(int position, ArrayList<LookData> lookDataList, final Activity activity,
        LookFragment fragment) {//from  www  .  j ava  2  s  .c  o  m
    LookData lookData = lookDataList.get(position);

    try {
        String projectName = ProjectManager.getInstance().getCurrentProject().getName();

        StorageHandler.getInstance().copyImage(projectName, lookData.getAbsolutePath(), null);

        String imageName = lookData.getLookName() + "_"
                + activity.getString(hku.fyp14017.blencode.R.string.copy_addition);
        String imageFileName = lookData.getLookFileName();

        updateLookAdapter(imageName, imageFileName, lookDataList, fragment);
    } catch (IOException ioException) {
        Utils.showErrorDialog(activity, hku.fyp14017.blencode.R.string.error_load_image);
        Log.e(TAG, Log.getStackTraceString(ioException));
    }
    activity.sendBroadcast(new Intent(ScriptActivity.ACTION_BRICK_LIST_CHANGED));
}

From source file:org.catrobat.catroid.ui.controller.SoundController.java

private void copySoundToCatroid(String originalSoundPath, Activity activity, ArrayList<SoundInfo> soundList,
        SoundFragment fragment) {//from   ww  w  .  j  av a 2s . c  om
    try {
        File oldFile = new File(originalSoundPath);

        if (originalSoundPath.equals("")) {
            throw new IOException();
        }

        File soundFile = StorageHandler.getInstance().copySoundFile(originalSoundPath);

        String soundName;
        int extensionDotIndex = oldFile.getName().lastIndexOf('.');
        if (extensionDotIndex > 0) {
            soundName = oldFile.getName().substring(0, extensionDotIndex);
        } else {
            soundName = oldFile.getName();
        }

        String soundFileName = soundFile.getName();

        updateSoundAdapter(soundName, soundFileName, soundList, fragment);
    } catch (IOException e) {
        Utils.showErrorDialog(activity, R.string.error_load_sound);
    } catch (NullPointerException e) {
        Log.e("NullPointerException", "probably originalSoundPath null; message: " + e.getMessage());
        Utils.showErrorDialog(activity, R.string.error_load_sound);
    }
    activity.sendBroadcast(new Intent(ScriptActivity.ACTION_BRICK_LIST_CHANGED));
}