Example usage for android.content Intent EXTRA_TITLE

List of usage examples for android.content Intent EXTRA_TITLE

Introduction

In this page you can find the example usage for android.content Intent EXTRA_TITLE.

Prototype

String EXTRA_TITLE

To view the source code for android.content Intent EXTRA_TITLE.

Click Source Link

Document

A CharSequence dialog title to provide to the user when used with a #ACTION_CHOOSER .

Usage

From source file:eu.faircode.adblocker.ActivityLog.java

private Intent getIntentPCAPDocument() {
    Intent intent;//  ww w .ja  va2  s. c om
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        if (Util.isPackageInstalled("org.openintents.filemanager", this)) {
            intent = new Intent("org.openintents.action.PICK_DIRECTORY");
        } else {
            intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(
                    Uri.parse("https://play.google.com/store/apps/details?id=org.openintents.filemanager"));
        }
    } else {
        intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType("application/octet-stream");
        intent.putExtra(Intent.EXTRA_TITLE,
                "adblocker_" + new SimpleDateFormat("yyyyMMdd").format(new Date().getTime()) + ".pcap");
    }
    return intent;
}

From source file:org.woltage.irssiconnectbot.ConsoleActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    View view = findCurrentView(R.id.console_flip);
    final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);
    final boolean activeTerminal = (view instanceof TerminalView);
    boolean sessionOpen = false;
    boolean disconnected = false;
    boolean canForwardPorts = false;

    if (activeTerminal) {
        TerminalBridge bridge = ((TerminalView) view).bridge;
        sessionOpen = bridge.isSessionOpen();
        disconnected = bridge.isDisconnected();
        canForwardPorts = bridge.canFowardPorts();
    }//from ww w.  java2 s .c  om

    menu.setQwertyMode(true);

    disconnect = menu.add(R.string.list_host_disconnect);
    if (hardKeyboard)
        disconnect.setAlphabeticShortcut('w');
    if (!sessionOpen && disconnected)
        disconnect.setTitle(R.string.console_menu_close);
    disconnect.setEnabled(activeTerminal);
    disconnect.setIcon(android.R.drawable.ic_menu_close_clear_cancel);
    disconnect.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            // disconnect or close the currently visible session
            TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);
            TerminalBridge bridge = terminalView.bridge;

            bridge.dispatchDisconnect(true);

            if (bound != null && prefs.getBoolean("unloadKeysOnDisconnect", true)) {
                bound.lockUnusedKeys();
            }
            return true;
        }
    });

    copy = menu.add(R.string.console_menu_copy);
    if (hardKeyboard)
        copy.setAlphabeticShortcut('c');
    copy.setIcon(android.R.drawable.ic_menu_set_as);
    copy.setEnabled(activeTerminal);
    copy.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            // mark as copying and reset any previous bounds
            TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);
            copySource = terminalView.bridge;

            SelectionArea area = copySource.getSelectionArea();
            area.reset();
            area.setBounds(copySource.buffer.getColumns(), copySource.buffer.getRows());
            area.setRow(copySource.buffer.getCursorRow());
            area.setColumn(copySource.buffer.getCursorColumn());

            copySource.setSelectingForCopy(true);

            // Make sure we show the initial selection
            copySource.redraw();

            Toast.makeText(ConsoleActivity.this, getString(R.string.console_copy_start), Toast.LENGTH_LONG)
                    .show();
            return true;
        }
    });

    paste = menu.add(R.string.console_menu_paste);
    if (hardKeyboard)
        paste.setAlphabeticShortcut('v');
    paste.setIcon(android.R.drawable.ic_menu_edit);
    paste.setEnabled(clipboard.hasText() && sessionOpen);
    paste.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            // force insert of clipboard text into current console
            TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);
            TerminalBridge bridge = terminalView.bridge;

            // pull string from clipboard and generate all events to force
            // down
            String clip = clipboard.getText().toString();
            bridge.injectString(clip);

            return true;
        }
    });

    portForward = menu.add(R.string.console_menu_portforwards);
    if (hardKeyboard)
        portForward.setAlphabeticShortcut('f');
    portForward.setIcon(android.R.drawable.ic_menu_manage);
    portForward.setEnabled(sessionOpen && canForwardPorts);
    portForward.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);
            TerminalBridge bridge = terminalView.bridge;

            Intent intent = new Intent(ConsoleActivity.this, PortForwardListActivity.class);
            intent.putExtra(Intent.EXTRA_TITLE, bridge.host.getId());
            ConsoleActivity.this.startActivityForResult(intent, REQUEST_EDIT);
            return true;
        }
    });

    urlscan = menu.add(R.string.console_menu_urlscan);
    if (hardKeyboard)
        urlscan.setAlphabeticShortcut('u');
    urlscan.setIcon(android.R.drawable.ic_menu_search);
    urlscan.setEnabled(activeTerminal);
    urlscan.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            final TerminalView terminal = (TerminalView) findCurrentView(R.id.console_flip);

            TerminalKeyListener handler = terminal.bridge.getKeyHandler();
            handler.urlScan(terminal);

            return true;
        }
    });

    resize = menu.add(R.string.console_menu_resize);
    if (hardKeyboard)
        resize.setAlphabeticShortcut('s');
    resize.setIcon(android.R.drawable.ic_menu_crop);
    resize.setEnabled(sessionOpen);
    resize.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);

            final View resizeView = inflater.inflate(R.layout.dia_resize, null, false);
            ((EditText) resizeView.findViewById(R.id.width))
                    .setText(prefs.getString("default_fsize_width", "80"));
            ((EditText) resizeView.findViewById(R.id.height))
                    .setText(prefs.getString("default_fsize_height", "25"));

            new AlertDialog.Builder(ConsoleActivity.this).setView(resizeView)
                    .setPositiveButton(R.string.button_resize, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            int width, height;
                            try {
                                width = Integer.parseInt(
                                        ((EditText) resizeView.findViewById(R.id.width)).getText().toString());
                                height = Integer.parseInt(
                                        ((EditText) resizeView.findViewById(R.id.height)).getText().toString());
                            } catch (NumberFormatException nfe) {
                                // TODO change this to a real dialog where we can
                                // make the input boxes turn red to indicate an error.
                                return;
                            }
                            if (width > 0 && height > 0) {
                                terminalView.forceSize(width, height);
                                terminalView.bridge.parentChanged(terminalView);
                            } else {
                                new AlertDialog.Builder(ConsoleActivity.this)
                                        .setMessage("Width and height must be higher than zero.")
                                        .setTitle("Error").show();
                            }
                        }
                    }).setNegativeButton(android.R.string.cancel, null).create().show();

            return true;
        }
    });

    MenuItem ctrlKey = menu.add("Ctrl");
    ctrlKey.setEnabled(activeTerminal);
    ctrlKey.setIcon(R.drawable.button_ctrl);
    MenuItemCompat.setShowAsAction(ctrlKey, MenuItem.SHOW_AS_ACTION_IF_ROOM);
    ctrlKey.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            View flip = findCurrentView(R.id.console_flip);
            if (flip == null)
                return false;

            TerminalView terminal = (TerminalView) flip;

            TerminalKeyListener handler = terminal.bridge.getKeyHandler();
            handler.metaPress(TerminalKeyListener.META_CTRL_ON);
            terminal.bridge.tryKeyVibrate();
            return true;
        }
    });

    MenuItem escKey = menu.add("Esc");
    escKey.setEnabled(activeTerminal);
    escKey.setIcon(R.drawable.button_esc);
    MenuItemCompat.setShowAsAction(escKey, MenuItem.SHOW_AS_ACTION_IF_ROOM);
    escKey.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            View flip = findCurrentView(R.id.console_flip);
            if (flip == null)
                return false;

            TerminalView terminal = (TerminalView) flip;

            TerminalKeyListener handler = terminal.bridge.getKeyHandler();
            handler.sendEscape();
            terminal.bridge.tryKeyVibrate();
            return true;
        }
    });

    MenuItem symKey = menu.add("SYM");
    symKey.setEnabled(activeTerminal);
    symKey.setIcon(R.drawable.button_sym);
    MenuItemCompat.setShowAsAction(symKey, MenuItem.SHOW_AS_ACTION_IF_ROOM);
    symKey.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            View flip = findCurrentView(R.id.console_flip);
            if (flip == null)
                return false;

            TerminalView terminal = (TerminalView) flip;

            TerminalKeyListener handler = terminal.bridge.getKeyHandler();
            handler.showCharPickerDialog(terminal);
            return true;
        }
    });

    MenuItem inputButton = menu.add("Input");
    inputButton.setEnabled(activeTerminal);
    inputButton.setIcon(R.drawable.button_input);
    MenuItemCompat.setShowAsAction(inputButton, MenuItem.SHOW_AS_ACTION_IF_ROOM);
    inputButton.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            View flip = findCurrentView(R.id.console_flip);
            if (flip == null)
                return false;

            final TerminalView terminal = (TerminalView) flip;
            Thread promptThread = new Thread(new Runnable() {
                public void run() {
                    String inj = getCurrentPromptHelper().requestStringPrompt(null, "");
                    terminal.bridge.injectString(inj);
                }
            });
            promptThread.setName("Prompt");
            promptThread.setDaemon(true);
            promptThread.start();
            return true;
        }
    });

    MenuItem keyboard = menu.add("Show Keyboard");
    keyboard.setEnabled(activeTerminal);
    keyboard.setIcon(R.drawable.button_keyboard);
    MenuItemCompat.setShowAsAction(keyboard, MenuItem.SHOW_AS_ACTION_IF_ROOM);
    keyboard.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            View flip = findCurrentView(R.id.console_flip);
            if (flip == null)
                return false;

            inputManager.showSoftInput(flip, InputMethodManager.SHOW_FORCED);
            return true;
        }
    });

    MenuItem keys = menu.add(R.string.console_menu_pubkeys);
    keys.setIcon(android.R.drawable.ic_lock_lock);
    keys.setIntent(new Intent(this, PubkeyListActivity.class));
    keys.setEnabled(activeTerminal);
    keys.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            Intent intent = new Intent(ConsoleActivity.this, PubkeyListActivity.class);
            intent.putExtra(PubkeyListActivity.PICK_MODE, true);
            ConsoleActivity.this.startActivityForResult(intent, REQUEST_SELECT);
            return true;
        }
    });

    return true;
}

From source file:com.maskyn.fileeditorpro.activity.MainActivity.java

private void saveTheFile(boolean saveAs) {
    if (!saveAs && greatUri != null && greatUri.getUri() != null && greatUri.getUri() != Uri.EMPTY)
        new SaveFileTask(this, greatUri, pageSystem.getAllText(mEditor.getText().toString()), currentEncoding,
                new SaveFileTask.SaveFileInterface() {
                    @Override//from w ww .  ja  v a 2  s .  c om
                    public void fileSaved(Boolean success) {
                        savedAFile(greatUri, true);
                    }
                }).execute();
    else {
        if (Device.hasKitKatApi() && PreferenceHelper.getUseStorageAccessFramework(this)) {
            Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
            intent.setType("*/*");
            intent.putExtra(Intent.EXTRA_TITLE, greatUri.getFileName());
            startActivityForResult(intent, SAVE_AS_REQUEST_CODE);
        } else {
            new NewFileDetailsDialog(greatUri, pageSystem.getAllText(mEditor.getText().toString()),
                    currentEncoding).show(getFragmentManager().beginTransaction(), "dialog");
        }

    }
}

From source file:com.example.google.play.apkx.SampleDownloaderActivity.java

/**
 * This starts the movie by starting the video player activity with a
 * content URI for our custom APK extension content provider.
 *//*from   w ww  .  java 2  s .  c o  m*/
private void startMovie() {
    // launch the movie player activity
    Uri mediaUri = Uri.withAppendedPath(SampleZipFileProvider.ASSET_URI, "big_buck_bunny_720p_surround.m4v");
    Intent intent = new Intent();
    intent.setData(mediaUri);
    intent.putExtra(Intent.EXTRA_TITLE, mediaUri.getLastPathSegment());
    intent.setClass(this, SampleVideoPlayerActivity.class);
    startActivity(intent);
    finish();
}

From source file:org.connectbot.ConsoleFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.disconnect: {
        // disconnect or close the currently visible session
        final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);
        final TerminalBridge bridge = terminalView.bridge;

        bridge.dispatchDisconnect(true);
        return true;
    }/*from w  w  w.  j ava 2  s .  c  o  m*/
    case R.id.copy: {
        // mark as copying and reset any previous bounds
        final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);
        copySource = terminalView.bridge;

        final SelectionArea area = copySource.getSelectionArea();
        area.reset();
        area.setBounds(copySource.buffer.getColumns(), copySource.buffer.getRows());

        copySource.setSelectingForCopy(true);

        // Make sure we show the initial selection
        copySource.redraw();

        Toast.makeText(getActivity(), getString(R.string.console_copy_start), Toast.LENGTH_LONG).show();
        return true;
    }
    case R.id.paste: {
        // force insert of clipboard text into current console
        final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);
        final TerminalBridge bridge = terminalView.bridge;

        // pull string from clipboard and generate all events to force down
        final String clip = clipboard.getText().toString();
        bridge.injectString(clip);

        return true;
    }
    case R.id.port_forwards: {
        final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);
        final TerminalBridge bridge = terminalView.bridge;

        final Intent intent = new Intent(getActivity(), PortForwardListActivity.class);
        intent.putExtra(Intent.EXTRA_TITLE, bridge.host.getId());

        startActivityForResult(intent, REQUEST_EDIT);

        return true;
    }
    case R.id.url_scan: {
        final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);

        final List<String> urls = terminalView.bridge.scanForURLs();

        final Dialog urlDialog = new Dialog(getActivity());
        urlDialog.setTitle(R.string.console_menu_urlscan);

        ListView urlListView = new ListView(getActivity());

        final URLItemListener urlListener = new URLItemListener(getActivity());
        urlListView.setOnItemClickListener(urlListener);

        urlListView
                .setAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, urls));
        urlDialog.setContentView(urlListView);
        urlDialog.show();

        return true;
    }
    case R.id.resize: {
        final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);

        final View resizeView = inflater.inflate(R.layout.dia_resize, null, false);
        new AlertDialog.Builder(getActivity()).setView(resizeView)
                .setPositiveButton(R.string.button_resize, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        final int width, height;
                        try {
                            width = Integer.parseInt(
                                    ((EditText) resizeView.findViewById(R.id.width)).getText().toString());
                            height = Integer.parseInt(
                                    ((EditText) resizeView.findViewById(R.id.height)).getText().toString());
                        } catch (NumberFormatException nfe) {
                            // TODO change this to a real dialog where we can
                            // make the input boxes turn red to indicate an error.
                            return;
                        }

                        terminalView.forceSize(width, height);
                    }
                }).setNegativeButton(android.R.string.cancel, null).create().show();

        return true;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:org.schabi.newpipe.VideoItemDetailFragment.java

private void setupActionBarHandler(final StreamInfo info) {
    actionBarHandler.setupStreamList(info.video_streams);

    actionBarHandler.setOnShareListener(new ActionBarHandler.OnActionListener() {
        @Override//from  w  ww  .  j  a v  a 2  s.c  om
        public void onActionSelected(int selectedStreamId) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_SEND);
            intent.putExtra(Intent.EXTRA_TEXT, info.webpage_url);
            intent.setType("text/plain");
            activity.startActivity(
                    Intent.createChooser(intent, activity.getString(R.string.share_dialog_title)));
        }
    });

    actionBarHandler.setOnOpenInBrowserListener(new ActionBarHandler.OnActionListener() {
        @Override
        public void onActionSelected(int selectedStreamId) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(info.webpage_url));

            activity.startActivity(Intent.createChooser(intent, activity.getString(R.string.choose_browser)));
        }
    });

    actionBarHandler.setOnPlayWithKodiListener(new ActionBarHandler.OnActionListener() {
        @Override
        public void onActionSelected(int selectedStreamId) {
            try {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setPackage(KORE_PACKET);
                intent.setData(Uri.parse(info.webpage_url.replace("https", "http")));
                activity.startActivity(intent);
            } catch (Exception e) {
                e.printStackTrace();
                AlertDialog.Builder builder = new AlertDialog.Builder(activity);
                builder.setMessage(R.string.kore_not_found)
                        .setPositiveButton(R.string.install, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                Intent intent = new Intent();
                                intent.setAction(Intent.ACTION_VIEW);
                                intent.setData(Uri.parse(activity.getString(R.string.fdroid_kore_url)));
                                activity.startActivity(intent);
                            }
                        }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                            }
                        });
                builder.create().show();
            }
        }
    });

    actionBarHandler.setOnDownloadListener(new ActionBarHandler.OnActionListener() {
        @Override
        public void onActionSelected(int selectedStreamId) {
            try {
                Bundle args = new Bundle();

                // Sometimes it may be that some information is not available due to changes fo the
                // website which was crawled. Then the ui has to understand this and act right.

                if (info.audio_streams != null) {
                    AudioStream audioStream = info.audio_streams.get(getPreferredAudioStreamId(info));

                    String audioSuffix = "." + MediaFormat.getSuffixById(audioStream.format);
                    args.putString(DownloadDialog.AUDIO_URL, audioStream.url);
                    args.putString(DownloadDialog.FILE_SUFFIX_AUDIO, audioSuffix);
                }

                if (info.video_streams != null) {
                    VideoStream selectedStreamItem = info.video_streams.get(selectedStreamId);
                    String videoSuffix = "." + MediaFormat.getSuffixById(selectedStreamItem.format);
                    args.putString(DownloadDialog.FILE_SUFFIX_VIDEO, videoSuffix);
                    args.putString(DownloadDialog.VIDEO_URL, selectedStreamItem.url);
                }

                args.putString(DownloadDialog.TITLE, info.title);
                DownloadDialog downloadDialog = DownloadDialog.newInstance(args);
                downloadDialog.show(activity.getSupportFragmentManager(), "downloadDialog");
            } catch (Exception e) {
                Toast.makeText(VideoItemDetailFragment.this.getActivity(),
                        R.string.could_not_setup_download_menu, Toast.LENGTH_LONG).show();
                e.printStackTrace();
            }
        }
    });

    if (info.audio_streams == null) {
        actionBarHandler.showAudioAction(false);
    } else {
        actionBarHandler.setOnPlayAudioListener(new ActionBarHandler.OnActionListener() {
            @Override
            public void onActionSelected(int selectedStreamId) {
                boolean useExternalAudioPlayer = PreferenceManager.getDefaultSharedPreferences(activity)
                        .getBoolean(activity.getString(R.string.use_external_audio_player_key), false);
                Intent intent;
                AudioStream audioStream = info.audio_streams.get(getPreferredAudioStreamId(info));
                if (!useExternalAudioPlayer && android.os.Build.VERSION.SDK_INT >= 18) {
                    //internal music player: explicit intent
                    if (!BackgroundPlayer.isRunning && videoThumbnail != null) {
                        ActivityCommunicator.getCommunicator().backgroundPlayerThumbnail = videoThumbnail;
                        intent = new Intent(activity, BackgroundPlayer.class);

                        intent.setAction(Intent.ACTION_VIEW);
                        Log.i(TAG, "audioStream is null:" + (audioStream == null));
                        Log.i(TAG, "audioStream.url is null:" + (audioStream.url == null));
                        intent.setDataAndType(Uri.parse(audioStream.url),
                                MediaFormat.getMimeById(audioStream.format));
                        intent.putExtra(BackgroundPlayer.TITLE, info.title);
                        intent.putExtra(BackgroundPlayer.WEB_URL, info.webpage_url);
                        intent.putExtra(BackgroundPlayer.SERVICE_ID, streamingServiceId);
                        intent.putExtra(BackgroundPlayer.CHANNEL_NAME, info.uploader);
                        activity.startService(intent);
                    }
                } else {
                    intent = new Intent();
                    try {
                        intent.setAction(Intent.ACTION_VIEW);
                        intent.setDataAndType(Uri.parse(audioStream.url),
                                MediaFormat.getMimeById(audioStream.format));
                        intent.putExtra(Intent.EXTRA_TITLE, info.title);
                        intent.putExtra("title", info.title);
                        // HERE !!!
                        activity.startActivity(intent);
                    } catch (Exception e) {
                        e.printStackTrace();
                        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
                        builder.setMessage(R.string.no_player_found)
                                .setPositiveButton(R.string.install, new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        Intent intent = new Intent();
                                        intent.setAction(Intent.ACTION_VIEW);
                                        intent.setData(Uri.parse(activity.getString(R.string.fdroid_vlc_url)));
                                        activity.startActivity(intent);
                                    }
                                }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        Log.i(TAG, "You unlocked a secret unicorn.");
                                    }
                                });
                        builder.create().show();
                        Log.e(TAG,
                                "Either no Streaming player for audio was installed, or something important crashed:");
                        e.printStackTrace();
                    }
                }
            }
        });
    }
}

From source file:com.justone.android.main.MainActivity.java

public void shareOnClick(View view) {
    String shareTitle = "";
    String shareContent = "    ";
    if (tabs.getCurrentTabTag() == "home tab") {
        shareTitle = "home tab";
        shareContent = shareContent + ((TextView) this.findViewById(R.id.fPage_tView)).getText().toString()
                + ((TextView) this.findViewById(R.id.imageBelow_tView)).getText().toString()
                + "()  " + ((TextView) this.findViewById(R.id.home_share_url)).getText().toString();
    } else if (tabs.getCurrentTabTag() == "QA Tab") {
        shareTitle = "QA Tab";
        shareContent = shareContent + ((TextView) this.findViewById(R.id.question_content)).getText().toString()
                + " -  ()  "
                + ((TextView) this.findViewById(R.id.qa_share_url)).getText().toString();

    } else if (tabs.getCurrentTabTag() == "list tab") {
        shareTitle = "list tab";
        shareContent = shareContent + ""
                + ((TextView) this.findViewById(R.id.one_content_title)).getText().toString() + " by "
                + ((TextView) this.findViewById(R.id.one_content_author)).getText().toString()
                + "- ()  "
                + ((TextView) this.findViewById(R.id.list_share_url)).getText().toString();

    }//from w  w w  .  j  ava2s .  c  om

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    // intent.setPackage("com.sina.weibo");
    intent.putExtra(Intent.EXTRA_SUBJECT, "");
    //intent.putExtra(Intent.EXTRA_TEXT, shareTitle+"   VOL.516   () http://caodan.org/516-photo.html ");
    intent.putExtra(Intent.EXTRA_TEXT, shareContent);
    intent.putExtra(Intent.EXTRA_TITLE, shareTitle);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(Intent.createChooser(intent, ""));
}

From source file:org.schabi.newpipe.detail.VideoItemDetailFragment.java

public void playVideo(final StreamInfo info) {
    // ----------- THE MAGIC MOMENT ---------------
    VideoStream selectedVideoStream = info.video_streams.get(actionBarHandler.getSelectedVideoStream());

    if (PreferenceManager.getDefaultSharedPreferences(activity)
            .getBoolean(activity.getString(R.string.use_external_video_player_key), false)) {

        // External Player
        Intent intent = new Intent();
        try {/*w w w  . j a v  a2s  .  c  o m*/
            intent.setAction(Intent.ACTION_VIEW)
                    .setDataAndType(Uri.parse(selectedVideoStream.url),
                            MediaFormat.getMimeById(selectedVideoStream.format))
                    .putExtra(Intent.EXTRA_TITLE, info.title).putExtra("title", info.title);

            activity.startActivity(intent); // HERE !!!
        } catch (Exception e) {
            e.printStackTrace();
            AlertDialog.Builder builder = new AlertDialog.Builder(activity);
            builder.setMessage(R.string.no_player_found)
                    .setPositiveButton(R.string.install, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Intent intent = new Intent().setAction(Intent.ACTION_VIEW)
                                    .setData(Uri.parse(activity.getString(R.string.fdroid_vlc_url)));
                            activity.startActivity(intent);
                        }
                    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    });
            builder.create().show();
        }
    } else {
        if (PreferenceManager.getDefaultSharedPreferences(activity)
                .getBoolean(activity.getString(R.string.use_exoplayer_key), false)) {

            // exo player

            if (info.dashMpdUrl != null && !info.dashMpdUrl.isEmpty()) {
                // try dash
                Intent intent = new Intent(activity, ExoPlayerActivity.class)
                        .setData(Uri.parse(info.dashMpdUrl))
                        .putExtra(ExoPlayerActivity.CONTENT_TYPE_EXTRA, Util.TYPE_DASH);
                startActivity(intent);
            } else if ((info.audio_streams != null && !info.audio_streams.isEmpty())
                    && (info.video_only_streams != null && !info.video_only_streams.isEmpty())) {
                // try smooth streaming

            } else {
                //default streaming
                Intent intent = new Intent(activity, ExoPlayerActivity.class)
                        .setDataAndType(Uri.parse(selectedVideoStream.url),
                                MediaFormat.getMimeById(selectedVideoStream.format))
                        .putExtra(ExoPlayerActivity.CONTENT_TYPE_EXTRA, Util.TYPE_OTHER);

                activity.startActivity(intent); // HERE !!!
            }
            //-------------

        } else {
            // Internal Player
            Intent intent = new Intent(activity, PlayVideoActivity.class)
                    .putExtra(PlayVideoActivity.VIDEO_TITLE, info.title)
                    .putExtra(PlayVideoActivity.STREAM_URL, selectedVideoStream.url)
                    .putExtra(PlayVideoActivity.VIDEO_URL, info.webpage_url)
                    .putExtra(PlayVideoActivity.START_POSITION, info.start_position);
            activity.startActivity(intent); //also HERE !!!
        }
    }

    // --------------------------------------------
}

From source file:org.drrickorang.loopback.LoopbackActivity.java

/**
 * Save five files: one .png file for a screenshot on the main activity, one .wav file for
 * the plot displayed on the main activity, one .txt file for storing various test results, one
 * .txt file for storing recorder buffer period data, and one .txt file for storing player
 * buffer period data./* w  ww  .  ja va2s.  com*/
 */
public void onButtonSave(View view) {
    if (!isBusy()) {
        //create filename with date
        String date = mCurrentTime; // the time the plot is acquired
        //String micSource = getApp().getMicSourceString(getApp().getMicSource());
        String fileName = "loopback_" + date;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TITLE, fileName + ".txt"); //suggested filename
            startActivityForResult(intent, SAVE_TO_TXT_REQUEST);

            Intent intent2 = new Intent(Intent.ACTION_CREATE_DOCUMENT);
            intent2.addCategory(Intent.CATEGORY_OPENABLE);
            intent2.setType("image/png");
            intent2.putExtra(Intent.EXTRA_TITLE, fileName + ".png"); //suggested filename
            startActivityForResult(intent2, SAVE_TO_PNG_REQUEST);

            //sometimes ".wav" will be added automatically, sometimes not
            Intent intent3 = new Intent(Intent.ACTION_CREATE_DOCUMENT);
            intent3.addCategory(Intent.CATEGORY_OPENABLE);
            intent3.setType("audio/wav");
            intent3.putExtra(Intent.EXTRA_TITLE, fileName + ".wav"); //suggested filename
            startActivityForResult(intent3, SAVE_TO_WAVE_REQUEST);

            fileName = "loopback_" + date + "_recorderBufferPeriod";
            Intent intent4 = new Intent(Intent.ACTION_CREATE_DOCUMENT);
            intent4.addCategory(Intent.CATEGORY_OPENABLE);
            intent4.setType("text/plain");
            intent4.putExtra(Intent.EXTRA_TITLE, fileName + ".txt");
            startActivityForResult(intent4, SAVE_RECORDER_BUFFER_PERIOD_TO_TXT_REQUEST);

            fileName = "loopback_" + date + "_playerBufferPeriod";
            Intent intent5 = new Intent(Intent.ACTION_CREATE_DOCUMENT);
            intent5.addCategory(Intent.CATEGORY_OPENABLE);
            intent5.setType("text/plain");
            intent5.putExtra(Intent.EXTRA_TITLE, fileName + ".txt");
            startActivityForResult(intent5, SAVE_PLAYER_BUFFER_PERIOD_TO_TXT_REQUEST);
        } else {
            saveAllTo(fileName);
        }
    } else {
        showToast("Test in progress... please wait");
    }
}

From source file:org.connectbot.ConsoleActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    TerminalView view = adapter.getCurrentTerminalView();
    final boolean activeTerminal = view != null;
    boolean sessionOpen = false;
    boolean disconnected = false;
    boolean canForwardPorts = false;

    if (activeTerminal) {
        TerminalBridge bridge = view.bridge;
        sessionOpen = bridge.isSessionOpen();
        disconnected = bridge.isDisconnected();
        canForwardPorts = bridge.canFowardPorts();
    }//w  ww  .  ja  v  a  2 s  . co  m

    menu.setQwertyMode(true);

    disconnect = menu.add(R.string.list_host_disconnect);
    if (hardKeyboard)
        disconnect.setAlphabeticShortcut('w');
    if (!sessionOpen && disconnected)
        disconnect.setTitle(R.string.console_menu_close);
    disconnect.setEnabled(activeTerminal);
    disconnect.setIcon(android.R.drawable.ic_menu_close_clear_cancel);
    disconnect.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            // disconnect or close the currently visible session
            TerminalView terminalView = adapter.getCurrentTerminalView();
            TerminalBridge bridge = terminalView.bridge;

            bridge.dispatchDisconnect(true);
            return true;
        }
    });

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        copy = menu.add(R.string.console_menu_copy);
        if (hardKeyboard)
            copy.setAlphabeticShortcut('c');
        MenuItemCompat.setShowAsAction(copy, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
        copy.setIcon(R.drawable.ic_action_copy);
        copy.setEnabled(activeTerminal);
        copy.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                adapter.getCurrentTerminalView().startPreHoneycombCopyMode();
                Toast.makeText(ConsoleActivity.this, getString(R.string.console_copy_start), Toast.LENGTH_LONG)
                        .show();
                return true;
            }
        });
    }

    paste = menu.add(R.string.console_menu_paste);
    if (hardKeyboard)
        paste.setAlphabeticShortcut('v');
    MenuItemCompat.setShowAsAction(paste, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
    paste.setIcon(R.drawable.ic_action_paste);
    paste.setEnabled(activeTerminal);
    paste.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            pasteIntoTerminal();
            return true;
        }
    });

    portForward = menu.add(R.string.console_menu_portforwards);
    if (hardKeyboard)
        portForward.setAlphabeticShortcut('f');
    portForward.setIcon(android.R.drawable.ic_menu_manage);
    portForward.setEnabled(sessionOpen && canForwardPorts);
    portForward.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            TerminalView terminalView = adapter.getCurrentTerminalView();
            TerminalBridge bridge = terminalView.bridge;

            Intent intent = new Intent(ConsoleActivity.this, PortForwardListActivity.class);
            intent.putExtra(Intent.EXTRA_TITLE, bridge.host.getId());
            ConsoleActivity.this.startActivityForResult(intent, REQUEST_EDIT);
            return true;
        }
    });

    urlscan = menu.add(R.string.console_menu_urlscan);
    if (hardKeyboard)
        urlscan.setAlphabeticShortcut('u');
    urlscan.setIcon(android.R.drawable.ic_menu_search);
    urlscan.setEnabled(activeTerminal);
    urlscan.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            final TerminalView terminalView = adapter.getCurrentTerminalView();

            List<String> urls = terminalView.bridge.scanForURLs();

            Dialog urlDialog = new Dialog(ConsoleActivity.this);
            urlDialog.setTitle(R.string.console_menu_urlscan);

            ListView urlListView = new ListView(ConsoleActivity.this);
            URLItemListener urlListener = new URLItemListener(ConsoleActivity.this);
            urlListView.setOnItemClickListener(urlListener);

            urlListView.setAdapter(
                    new ArrayAdapter<String>(ConsoleActivity.this, android.R.layout.simple_list_item_1, urls));
            urlDialog.setContentView(urlListView);
            urlDialog.show();

            return true;
        }
    });

    resize = menu.add(R.string.console_menu_resize);
    if (hardKeyboard)
        resize.setAlphabeticShortcut('s');
    resize.setIcon(android.R.drawable.ic_menu_crop);
    resize.setEnabled(sessionOpen);
    resize.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            final TerminalView terminalView = adapter.getCurrentTerminalView();

            @SuppressLint("InflateParams") // Dialogs do not have a parent view.
            final View resizeView = inflater.inflate(R.layout.dia_resize, null, false);
            new android.support.v7.app.AlertDialog.Builder(ConsoleActivity.this, R.style.AlertDialogTheme)
                    .setView(resizeView)
                    .setPositiveButton(R.string.button_resize, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            int width, height;
                            try {
                                width = Integer.parseInt(
                                        ((EditText) resizeView.findViewById(R.id.width)).getText().toString());
                                height = Integer.parseInt(
                                        ((EditText) resizeView.findViewById(R.id.height)).getText().toString());
                            } catch (NumberFormatException nfe) {
                                // TODO change this to a real dialog where we can
                                // make the input boxes turn red to indicate an error.
                                return;
                            }

                            terminalView.forceSize(width, height);
                        }
                    }).setNegativeButton(android.R.string.cancel, null).create().show();

            return true;
        }
    });

    return true;
}