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:com.repkap11.repcast.activities.LocalPlayerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.player_activity);
    mAquery = new AQuery(this);
    loadViews();//from  w  w  w .  j  a v  a2 s .  c  o  m
    mCastManager = VideoCastManager.getInstance();
    mCastManager.setCastControllerImmersive(false);
    setupControlsCallbacks();
    setupCastListener();
    String castPath;
    String mimeType = getIntent().getType();
    String title = getIntent().getStringExtra(Intent.EXTRA_TITLE);
    int trackType;
    int mediaType;
    if (mimeType.equals("video/mp4")) {
        trackType = MediaTrack.TYPE_VIDEO;
        mediaType = MediaMetadata.MEDIA_TYPE_MOVIE;
    } else if (mimeType.equals("audio/mpeg")) {
    } else {
        trackType = MediaTrack.TYPE_UNKNOWN;
        mediaType = MediaMetadata.MEDIA_TYPE_GENERIC;
    }
    trackType = MediaTrack.TYPE_VIDEO;
    mediaType = MediaMetadata.MEDIA_TYPE_MOVIE;
    try {
        URL url = new URI(getIntent().getDataString()).toURL();
        castPath = url.toExternalForm();
        if (title == null) {
            title = new File(url.getPath()).getName();
        }
    } catch (MalformedURLException | URISyntaxException e) {
        e.printStackTrace();
        finish();
        return;
    }
    Log.e(TAG, "Cast Path:" + castPath);

    MediaInfo.Builder builder = new MediaInfo.Builder(castPath);
    builder.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED);
    builder.setContentType(mimeType);
    MediaMetadata metadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK);
    metadata.putString(MediaMetadata.KEY_TITLE, title);
    //metadata.putString(MediaMetadata.KEY_SUBTITLE, "Sub title Text");
    builder.setMetadata(metadata);
    JSONObject jsonObj = null;
    try {
        jsonObj = new JSONObject();
        jsonObj.put(VideoProvider.KEY_DESCRIPTION, "");
    } catch (JSONException e) {
        Log.e(TAG, "Failed to add description to the json object", e);
    }
    MediaTrack.Builder trackBuilder = new MediaTrack.Builder(1, MediaTrack.TYPE_VIDEO);

    //trackBuilder.setContentId(castPath);
    Log.e(TAG, "Setting path String: " + castPath);
    trackBuilder.setName(title);
    builder.setMediaTracks(Collections.singletonList(trackBuilder.build()));
    builder.setCustomData(jsonObj);
    mSelectedMedia = builder.build();
    setupActionBar();
    Bundle b = getIntent().getExtras();
    boolean shouldStartPlayback = false;
    int startPosition = 0;
    if (b != null) {
        shouldStartPlayback = b.getBoolean("shouldStart", false);
        startPosition = b.getInt("startPosition", 0);
    }
    mVideoView.setVideoURI(Uri.parse(mSelectedMedia.getContentId()));
    Log.e(TAG, "Setting url of the VideoView to: " + Uri.parse(mSelectedMedia.getContentId()));
    if (shouldStartPlayback) {
        // this will be the case only if we are coming from the
        // CastControllerActivity by disconnecting from a device
        mPlaybackState = PlaybackState.PLAYING;
        updatePlaybackLocation(PlaybackLocation.LOCAL);
        updatePlayButton(mPlaybackState);
        if (startPosition > 0) {
            mVideoView.seekTo(startPosition);
        }
        mVideoView.start();
        startControllersTimer();
    } else {
        // we should load the video but pause it
        // and show the album art.
        if (mCastManager.isConnected()) {
            updatePlaybackLocation(PlaybackLocation.REMOTE);
        } else {
            updatePlaybackLocation(PlaybackLocation.LOCAL);
        }
        mPlaybackState = PlaybackState.IDLE;
        updatePlayButton(mPlaybackState);
    }

    if (null != mTitleView) {
        updateMetadata(true);
    }
}

From source file:net.peterkuterna.android.apps.devoxxsched.ui.SpeakersGridFragment.java

@Override
public void onGridItemClick(GridView gv, View v, int position, long id) {
    final Cursor cursor = (Cursor) mAdapter.getItem(position);
    final String speakerId = cursor.getString(SpeakersAdapter.SpeakersQuery.SPEAKER_ID);
    final String firstName = cursor.getString(SpeakersAdapter.SpeakersQuery.SPEAKER_FIRSTNAME);
    final String lastName = cursor.getString(SpeakersAdapter.SpeakersQuery.SPEAKER_LASTNAME);
    final String speakerName = UIUtils.formatSpeakerName(firstName, lastName);
    final String title = getResources().getString(R.string.title_sessions_of, speakerName);
    AnalyticsUtils.getInstance(getActivity()).trackEvent("Speakers Grid", "Click", speakerName, 0);
    final Uri sessionsUri = CfpContract.Speakers.buildSessionsDirUri(speakerId);
    final Intent intent = new Intent(Intent.ACTION_VIEW, sessionsUri);
    intent.putExtra(Intent.EXTRA_TITLE, title);
    ((AbstractActivity) getActivity()).openActivityOrFragment(intent);
    if (UIUtils.isHoneycomb()) {
        getGridView().setItemChecked(position, true);
        mCheckedPosition = position;/*  w  w  w.  j  a  v a2 s. c om*/
    }
}

From source file:org.tunesremote.ArtistsListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {

    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;

    // create context menu to play entire artist
    try {/*www  .ja  v  a 2 s. co m*/
        Response resp = (Response) adapter.getItem(info.position);
        final String artist = resp.getString("mlit");
        menu.setHeaderTitle(artist);

        MenuItem play = menu.add(R.string.artists_menu_play);
        play.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                host.session.controlPlayArtist(artist, 0);
                host.setResult(Activity.RESULT_OK, new Intent());
                host.finish();
                return true;
            }
        });

        MenuItem queue = menu.add(R.string.artists_menu_queue);
        queue.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                host.session.controlQueueArtist(artist);
                host.setResult(Activity.RESULT_OK, new Intent());
                host.finish();
                return true;
            }
        });

        MenuItem browse = menu.add(R.string.artists_menu_browse);
        browse.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                Intent intent = new Intent(host, AlbumsActivity.class);
                intent.putExtra(Intent.EXTRA_TITLE, artist);
                host.startActivityForResult(intent, 1);
                return true;
            }
        });
    } catch (Exception e) {
        Log.w(TAG, "onCreateContextMenu:" + e.getMessage());
    }

}

From source file:com.avalond.ad_blocak.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    switch (item.getItemId()) {
    case R.id.action_restore:
        config = FileHelper.loadPreviousSettings(this);
        FileHelper.writeSettings(this, MainActivity.config);
        reload();/*from  w w w.  ja va  2  s  .c  o m*/
        break;
    case R.id.action_refresh:
        refresh();
        break;
    case R.id.action_load_defaults:
        config = FileHelper.loadDefaultSettings(this);
        reload();
        FileHelper.writeSettings(this, MainActivity.config);
        break;
    case R.id.action_import:
        Intent intent = new Intent().setType("*/*").setAction(Intent.ACTION_OPEN_DOCUMENT)
                .addCategory(Intent.CATEGORY_OPENABLE);

        startActivityForResult(intent, REQUEST_FILE_OPEN);
        break;
    case R.id.action_export:
        Intent exportIntent = new Intent(Intent.ACTION_CREATE_DOCUMENT).addCategory(Intent.CATEGORY_OPENABLE)
                .setType("*/*").putExtra(Intent.EXTRA_TITLE, "dns66.json");

        startActivityForResult(exportIntent, REQUEST_FILE_STORE);
        break;
    case R.id.action_about:
        Intent infoIntent = new Intent(this, InfoActivity.class);
        startActivity(infoIntent);
        break;
    }

    return super.onOptionsItemSelected(item);
}

From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.SpeakersGridFragment.java

@SuppressLint("NewApi")
@Override// w  ww  .j a v a2s .  co m
public void onGridItemClick(GridView gv, View v, int position, long id) {
    final Cursor cursor = (Cursor) mAdapter.getItem(position);
    final String speakerId = cursor.getString(SpeakersAdapter.SpeakersQuery.SPEAKER_ID);
    final String firstName = cursor.getString(SpeakersAdapter.SpeakersQuery.SPEAKER_FIRSTNAME);
    final String lastName = cursor.getString(SpeakersAdapter.SpeakersQuery.SPEAKER_LASTNAME);
    final String speakerName = UIUtils.formatSpeakerName(firstName, lastName);
    final String title = getResources().getString(R.string.title_sessions_of, speakerName);
    AnalyticsUtils.getInstance(getActivity()).trackEvent("Speakers Grid", "Click", speakerName, 0);
    final Uri sessionsUri = CfpContract.Speakers.buildSessionsDirUri(speakerId);
    final Intent intent = new Intent(Intent.ACTION_VIEW, sessionsUri);
    intent.putExtra(Intent.EXTRA_TITLE, title);
    ((AbstractActivity) getActivity()).openActivityOrFragment(intent);
    if (UIUtils.isHoneycombTablet(getActivity())) {
        getGridView().setItemChecked(position, true);
        mCheckedPosition = position;
    }
}

From source file:org.jak_linux.dns66.MainActivity.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    switch (item.getItemId()) {
    case R.id.action_restore:
        config = FileHelper.loadPreviousSettings(this);
        FileHelper.writeSettings(this, MainActivity.config);
        reload();//from  w  w w  .j  av a2  s. c o m
        break;
    case R.id.action_refresh:
        refresh();
        break;
    case R.id.action_load_defaults:
        config = FileHelper.loadDefaultSettings(this);
        reload();
        FileHelper.writeSettings(this, MainActivity.config);
        break;
    case R.id.action_import:
        Intent intent = new Intent().setType("*/*").setAction(Intent.ACTION_OPEN_DOCUMENT)
                .addCategory(Intent.CATEGORY_OPENABLE);

        startActivityForResult(intent, REQUEST_FILE_OPEN);
        break;
    case R.id.action_export:
        Intent exportIntent = new Intent(Intent.ACTION_CREATE_DOCUMENT).addCategory(Intent.CATEGORY_OPENABLE)
                .setType("*/*").putExtra(Intent.EXTRA_TITLE, "dns66.json");

        startActivityForResult(exportIntent, REQUEST_FILE_STORE);
        break;
    case R.id.setting_show_notification:
        // If we are enabling notifications, we do not need to show a dialog.
        if (!item.isChecked()) {
            item.setChecked(!item.isChecked());
            MainActivity.config.showNotification = item.isChecked();
            FileHelper.writeSettings(MainActivity.this, MainActivity.config);
            break;
        }
        new AlertDialog.Builder(this).setIcon(R.drawable.ic_warning)
                .setTitle(R.string.disable_notification_title).setMessage(R.string.disable_notification_message)
                .setPositiveButton(R.string.disable_notification_ack, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        item.setChecked(!item.isChecked());
                        MainActivity.config.showNotification = item.isChecked();
                        FileHelper.writeSettings(MainActivity.this, MainActivity.config);
                    }
                }).setNegativeButton(R.string.disable_notification_nak, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {

                    }
                }).show();
        break;
    case R.id.action_about:
        Intent infoIntent = new Intent(this, InfoActivity.class);
        startActivity(infoIntent);
        break;
    }

    return super.onOptionsItemSelected(item);
}

From source file:net.peterkuterna.android.apps.devoxxsched.ui.SpeakersListFragment.java

/** {@inheritDoc} */
@Override/*from   www  . j a v  a 2 s  .c  om*/
public void onListItemClick(ListView l, View v, int position, long id) {
    final Cursor cursor = (Cursor) mAdapter.getItem(position);
    final String speakerId = cursor.getString(SpeakersAdapter.SpeakersQuery.SPEAKER_ID);
    final String firstName = cursor.getString(SpeakersAdapter.SpeakersQuery.SPEAKER_FIRSTNAME);
    final String lastName = cursor.getString(SpeakersAdapter.SpeakersQuery.SPEAKER_LASTNAME);
    final String speakerName = UIUtils.formatSpeakerName(firstName, lastName);
    final String title = getResources().getString(R.string.title_sessions_of, speakerName);
    AnalyticsUtils.getInstance(getActivity()).trackEvent("Speakers List", "Click", speakerName, 0);
    final Uri sessionsUri = CfpContract.Speakers.buildSessionsDirUri(speakerId);
    final Intent intent = new Intent(Intent.ACTION_VIEW, sessionsUri);
    intent.putExtra(Intent.EXTRA_TITLE, title);
    ((AbstractActivity) getActivity()).openActivityOrFragment(intent);
    getListView().setItemChecked(position, true);
    mCheckedPosition = position;
}

From source file:net.peterkuterna.android.apps.devoxxsched.ui.BlockScheduleItemsFragment.java

/** {@inheritDoc} */
public void onClick(View view) {
    if (view instanceof ScheduleItemView) {
        final ScheduleItemView itemView = (ScheduleItemView) view;
        final ScheduleItem item = itemView.getScheduleItem();
        final String title = itemView.getText().toString();
        AnalyticsUtils.getInstance(getActivity()).trackEvent("Schedule", "Session Click", title, 0);
        final String id = item.getId();
        // final int sessionsCount = block.getSessionsCount();
        // if (sessionsCount == 1) {
        // final Uri sessionUri = CfpContract.Sessions
        // .buildSessionUri(block.getSessionId());
        // final Intent intent = new Intent(Intent.ACTION_VIEW, sessionUri);
        // ((BaseActivity) getSupportActivity())
        // .openActivityOrFragment(intent);
        // } else {
        final Uri sessionsUri = CfpContract.Blocks.buildSessionsUri(id);
        final Intent intent = new Intent(Intent.ACTION_VIEW, sessionsUri);
        intent.putExtra(Intent.EXTRA_TITLE, title);
        ((BaseActivity) getSupportActivity()).openActivityOrFragment(intent);
        // }/*from w w w. ja  va  2  s  . com*/
    }
}

From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.BlockScheduleItemsFragment.java

/** {@inheritDoc} */
public void onClick(View view) {
    if (view instanceof ScheduleItemView) {
        final ScheduleItemView itemView = (ScheduleItemView) view;
        final ScheduleItem item = itemView.getScheduleItem();
        final String title = itemView.getText().toString();
        AnalyticsUtils.getInstance(getActivity()).trackEvent("Schedule", "Session Click", title, 0);
        final String id = item.getId();
        // final int sessionsCount = block.getSessionsCount();
        // if (sessionsCount == 1) {
        // final Uri sessionUri = CfpContract.Sessions
        // .buildSessionUri(block.getSessionId());
        // final Intent intent = new Intent(Intent.ACTION_VIEW, sessionUri);
        // ((BaseActivity) getSupportActivity())
        // .openActivityOrFragment(intent);
        // } else {
        final Uri sessionsUri = CfpContract.Blocks.buildSessionsUri(id);
        final Intent intent = new Intent(Intent.ACTION_VIEW, sessionsUri);
        intent.putExtra(Intent.EXTRA_TITLE, title);
        ((BaseActivity) getActivity()).openActivityOrFragment(intent);
        // }// w  ww  .j  av  a 2  s  . c o m
    }
}

From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.SpeakersListFragment.java

/** {@inheritDoc} */
@Override/*from  ww w.j a  v  a  2s .  c  o m*/
public void onListItemClick(ListView l, View v, int position, long id) {
    final Cursor cursor = (Cursor) mAdapter.getItem(position);
    final String speakerId = cursor.getString(SpeakersAdapter.SpeakersQuery.SPEAKER_ID);
    final String firstName = cursor.getString(SpeakersAdapter.SpeakersQuery.SPEAKER_FIRSTNAME);
    final String lastName = cursor.getString(SpeakersAdapter.SpeakersQuery.SPEAKER_LASTNAME);
    final String speakerName = UIUtils.formatSpeakerName(firstName, lastName);
    final String title = getResources().getString(R.string.title_sessions_of, speakerName);
    AnalyticsUtils.getInstance(getActivity()).trackEvent("Speakers List", "Click", speakerName, 0);
    final Uri sessionsUri = CfpContract.Speakers.buildSessionsDirUri(speakerId);
    final Intent intent = new Intent(Intent.ACTION_VIEW, sessionsUri);
    intent.putExtra(Intent.EXTRA_TITLE, title);
    ((AbstractActivity) getActivity()).openActivityOrFragment(intent);
    if (UIUtils.isHoneycombTablet(getActivity())) {
        getListView().setItemChecked(position, true);
        mCheckedPosition = position;
    }
}