Example usage for android.content Intent EXTRA_STREAM

List of usage examples for android.content Intent EXTRA_STREAM

Introduction

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

Prototype

String EXTRA_STREAM

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

Click Source Link

Document

A content: URI holding a stream of data associated with the Intent, used with #ACTION_SEND to supply the data being sent.

Usage

From source file:com.hema.playViewUtil.ui.OnlineVideoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // ???//from   ww  w.  ja  v a2  s .com
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // ????
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_player);

    mSettings = new Settings(this);

    // handle arguments
    mVideoPath = getIntent().getStringExtra("videoPath");

    Intent intent = getIntent();
    String intentAction = intent.getAction();
    if (!TextUtils.isEmpty(intentAction)) {
        if (intentAction.equals(Intent.ACTION_VIEW)) {
            mVideoPath = intent.getDataString();
        } else if (intentAction.equals(Intent.ACTION_SEND)) {
            mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                String scheme = mVideoUri.getScheme();
                if (TextUtils.isEmpty(scheme)) {
                    Log.e(TAG, "Null unknown ccheme\n");
                    finish();
                    return;
                }
                if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
                    mVideoPath = mVideoUri.getPath();
                } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
                    Log.e(TAG, "Can not resolve content below Android-ICS\n");
                    finish();
                    return;
                } else {
                    Log.e(TAG, "Unknown scheme " + scheme + "\n");
                    finish();
                    return;
                }
            }
        }
    }

    if (!TextUtils.isEmpty(mVideoPath)) {
        new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
    }

    // init UI
    //        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    //        setSupportActionBar(toolbar);

    //        ActionBar actionBar = getSupportActionBar();
    mMediaController = new AndroidMediaController(this, false);
    //        mMediaController.setSupportActionBar(actionBar);

    mToastTextView = (TextView) findViewById(R.id.toast_text_view);
    mHudView = (TableLayout) findViewById(R.id.hud_view);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer);
    loading_icon = (ProgressBar) findViewById(R.id.loading_icon);

    mDrawerLayout.setScrimColor(Color.TRANSPARENT);

    // init player
    IjkMediaPlayer.loadLibrariesOnce(null);
    IjkMediaPlayer.native_profileBegin("libijkplayer.so");

    mVideoView = (IjkVideoView) findViewById(R.id.video_view);

    mVideoView.setMediaController(mMediaController);
    //        mVideoView.setHudView(mHudView);
    setListener();

    // prefer mVideoPath
    if (mVideoPath != null)
        mVideoView.setVideoPath(mVideoPath);
    else if (mVideoUri != null)
        mVideoView.setVideoURI(mVideoUri);
    else {
        Log.e(TAG, "Null Data Source\n");
        finish();
        return;
    }
    mVideoView.start();
}

From source file:de.dreier.mytargets.features.statistics.DispersionPatternActivity.java

private void shareImage() {
    // Construct share intent
    new Thread(() -> {
        try {//from w  w w.  j a v a 2s.com
            File dir = getCacheDir();
            final File f = File.createTempFile("dispersion_pattern", ".png", dir);
            DispersionPatternUtils.createDispersionPatternImageFile(800, f, statistic);

            // Build and fire intent to ask for share provider
            Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.setType("image/png");
            String packageName = getApplicationContext().getPackageName();
            String authority = packageName + ".easyphotopicker.fileprovider";
            shareIntent.putExtra(Intent.EXTRA_STREAM,
                    getUriForFile(DispersionPatternActivity.this, authority, f));
            startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
        } catch (IOException e) {
            e.printStackTrace();
            Snackbar.make(binding.getRoot(), R.string.sharing_failed, Snackbar.LENGTH_SHORT).show();
        }
    }).start();
}

From source file:at.bitfire.davdroid.ui.DebugInfoActivity.java

public void onShare(MenuItem item) {
    if (!TextUtils.isEmpty(report)) {
        Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.setType("text/plain");
        sendIntent.putExtra(Intent.EXTRA_SUBJECT,
                getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME + " debug info");

        // since Android 4.1, FileProvider permissions are handled in a useful way (using ClipData)
        boolean asAttachment = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;

        if (asAttachment)
            try {
                File debugInfoDir = new File(getCacheDir(), "debug-info");
                debugInfoDir.mkdir();//from www  .  jav  a  2  s .  c  o  m

                reportFile = new File(debugInfoDir, "debug.txt");
                App.log.fine("Writing debug info to " + reportFile.getAbsolutePath());
                FileWriter writer = new FileWriter(reportFile);
                writer.write(report);
                writer.close();

                sendIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this,
                        getString(R.string.authority_log_provider), reportFile));
                sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

            } catch (IOException e) {
                // creating an attachment failed, so send it inline
                asAttachment = false;

                StringBuilder builder = new StringBuilder();
                builder.append("Couldn't write debug info file:\n").append(ExceptionUtils.getStackTrace(e))
                        .append("\n\n").append(report);
                report = builder.toString();
            }

        if (!asAttachment)
            sendIntent.putExtra(Intent.EXTRA_TEXT, report);

        startActivity(Intent.createChooser(sendIntent, null));
    }
}

From source file:com.dynamixsoftware.printingsample.ShareIntentFragment.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.share_image_action_view: {
        String imageFilePath = FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG);
        Log.i("testtest", Uri.parse("file://" + imageFilePath).toString());

        if (imageFilePath != null) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse("file://" + imageFilePath), "image/png");
            if (startPrintHandActivityFailed(intent))
                showStartPrintHandActivityErrorDialog();
        } else//w w w . j  a  v a  2s . co  m
            showOpenFileErrorDialog();
        break;
    }
    case R.id.share_image_action_send: {
        String imageFilePath = FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG);
        if (imageFilePath != null) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("image/png");
            intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + imageFilePath));
            if (startPrintHandActivityFailed(intent))
                showStartPrintHandActivityErrorDialog();
        } else
            showOpenFileErrorDialog();
        break;
    }
    case R.id.share_image_multiple: {
        String imageFilePath = FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG);
        if (imageFilePath != null) {
            Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
            Uri uri = Uri.parse("file://" + imageFilePath);
            ArrayList<Uri> urisList = new ArrayList<>();
            urisList.add(uri);
            urisList.add(uri);
            urisList.add(uri);
            intent.putExtra(Intent.EXTRA_STREAM, urisList);
            intent.setType("image/*");
            if (startPrintHandActivityFailed(intent))
                showStartPrintHandActivityErrorDialog();
        } else {
            showOpenFileErrorDialog();
        }
        break;
    }
    case R.id.share_image_return: {
        String imageFilePath = FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG);
        if (imageFilePath != null) {
            Intent intent = new Intent(Intent.ACTION_VIEW); // can be ACTION_SEND - see share_image_action_send for properly configure intent
            intent.setDataAndType(Uri.parse("file://" + imageFilePath), "image/png");
            if (startPrintHandActivityForResultFailed(intent, REQUEST_CODE_IMAGE))
                showStartPrintHandActivityErrorDialog();
        } else
            showOpenFileErrorDialog();
        break;
    }
    case R.id.share_file: {
        String docFilePath = FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_DOC);
        if (docFilePath != null) {
            Intent intent = new Intent(Intent.ACTION_VIEW); // can be ACTION_SEND - see share_image_action_send for properly configure intent
            intent.setDataAndType(Uri.parse("file://" + docFilePath), "application/msword"); // scheme "content://" also available
            // MIME types available:
            // application/pdf
            // application/vnd.ms-word
            // application/ms-word
            // application/msword
            // application/vnd.openxmlformats-officedocument.wordprocessingml.document
            // application/vnd.ms-excel
            // application/ms-excel
            // application/msexcel
            // application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
            // application/vnd.ms-powerpoint
            // application/ms-powerpoint
            // application/mspowerpoint
            // application/vnd.openxmlformats-officedocument.presentationml.presentation
            // application/haansofthwp
            // text/plain
            // text/html
            if (startPrintHandActivityFailed(intent))
                showStartPrintHandActivityErrorDialog();
        } else
            showOpenFileErrorDialog();
        break;
    }
    case R.id.share_web_page_uri: {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.parse("http://printhand.com"), "text/html"); // worked only 'http' - bug in PrintHand?
        if (startPrintHandActivityFailed(intent))
            showStartPrintHandActivityErrorDialog();
        break;
    }
    case R.id.share_web_page_string: {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/html");
        intent.putExtra(Intent.EXTRA_TEXT, "https://printhand.com");
        if (startPrintHandActivityFailed(intent))
            showStartPrintHandActivityErrorDialog();
        break;
    }
    case R.id.activate_license: {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.putExtra(Intent.EXTRA_TEXT, "YOUR_KEY_HERE"); // put your activation key here
        intent.setType("text/license");
        intent.putExtra("showErrorMessage", true); // if true PrintHand shown error message
        intent.putExtra("return", false); // if true (and showErrorMessage is false) PrintHand provide result to your onActivityResult
        if (startPrintHandActivityFailed(intent))
            showStartPrintHandActivityErrorDialog();
        break;
    }
    case R.id.activate_license_return: {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.putExtra(Intent.EXTRA_TEXT, "YOUR_KEY_HERE"); // put your activation key here
        intent.setType("text/license");
        intent.putExtra("showErrorMessage", false); // if true PrintHand shown error message
        intent.putExtra("return", true); // if true (and showErrorMessage is false) PrintHand provide result to your onActivityResult
        if (startPrintHandActivityForResultFailed(intent, REQUEST_CODE_LICENSE))
            showStartPrintHandActivityErrorDialog();
        break;
    }
    }
}

From source file:ca.rmen.android.networkmonitor.app.about.AboutActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;
    case R.id.action_send_logs:
        new AsyncTask<Void, Void, Boolean>() {

            @Override/*from  w w  w.  j a  va 2s  . com*/
            protected Boolean doInBackground(Void... params) {
                if (!Log.prepareLogFile()) {
                    return false;
                }
                // Bring up the chooser to share the file.
                Intent sendIntent = new Intent();
                sendIntent.setAction(Intent.ACTION_SEND);
                //sendIntent.setData(Uri.fromParts("mailto", getString(R.string.send_logs_to), null));
                sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.support_send_debug_logs_subject));
                String messageBody = getString(R.string.support_send_debug_logs_body);
                File f = new File(getExternalFilesDir(null), Log.FILE);
                sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + f.getAbsolutePath()));
                sendIntent.setType("message/rfc822");
                sendIntent.putExtra(Intent.EXTRA_TEXT, messageBody);
                sendIntent.putExtra(Intent.EXTRA_EMAIL,
                        new String[] { getString(R.string.support_send_debug_logs_to) });
                startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.action_share)));
                return true;
            }

            @Override
            protected void onPostExecute(Boolean result) {
                if (!result)
                    Toast.makeText(AboutActivity.this, R.string.support_error, Toast.LENGTH_LONG).show();
            }

        }.execute();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.dm.material.dashboard.candybar.helpers.ReportBugsHelper.java

public static void checkForBugs(@NonNull Context context) {
    new AsyncTask<Void, Void, Boolean>() {

        MaterialDialog dialog;/*from   www . j a  va2  s.  c  o m*/
        StringBuilder sb;
        File folder;
        String file;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            sb = new StringBuilder();
            folder = FileHelper.getCacheDirectory(context);
            file = folder.toString() + "/" + "reportbugs.zip";

            MaterialDialog.Builder builder = new MaterialDialog.Builder(context);
            builder.content(R.string.report_bugs_building).progress(true, 0).progressIndeterminateStyle(true);

            dialog = builder.build();
            dialog.show();
        }

        @Override
        protected Boolean doInBackground(Void... voids) {
            while (!isCancelled()) {
                try {
                    Thread.sleep(1);
                    SparseArrayCompat<String> files = new SparseArrayCompat<>();
                    sb.append(DeviceHelper.getDeviceInfo(context));

                    String brokenAppFilter = buildBrokenAppFilter(context, folder);
                    if (brokenAppFilter != null)
                        files.append(files.size(), brokenAppFilter);

                    String activityList = buildActivityList(context, folder);
                    if (activityList != null)
                        files.append(files.size(), activityList);

                    String stackTrace = Preferences.getPreferences(context).getLatestCrashLog();
                    String crashLog = buildCrashLog(context, folder, stackTrace);
                    if (crashLog != null)
                        files.append(files.size(), crashLog);

                    FileHelper.createZip(files, file);
                    return true;
                } catch (Exception e) {
                    Log.d(Tag.LOG_TAG, Log.getStackTraceString(e));
                    return false;
                }
            }
            return false;
        }

        @Override
        protected void onPostExecute(Boolean aBoolean) {
            super.onPostExecute(aBoolean);
            dialog.dismiss();
            if (aBoolean) {
                File zip = new File(file);

                final Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("message/rfc822");
                intent.putExtra(Intent.EXTRA_EMAIL,
                        new String[] { context.getResources().getString(R.string.dev_email) });
                intent.putExtra(Intent.EXTRA_SUBJECT, "Report Bugs " + (context.getString(R.string.app_name)));
                intent.putExtra(Intent.EXTRA_TEXT, sb.toString());
                Uri uri = FileHelper.getUriFromFile(context, context.getPackageName(), zip);
                intent.putExtra(Intent.EXTRA_STREAM, uri);

                context.startActivity(
                        Intent.createChooser(intent, context.getResources().getString(R.string.email_client)));

            } else {
                Toast.makeText(context, R.string.report_bugs_failed, Toast.LENGTH_LONG).show();
            }

            dialog = null;
            sb.setLength(0);
        }
    }.execute();
}

From source file:com.ctg.ctvideo.activities.VideoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);

    mSettings = new Settings(this);

    // handle arguments
    mVideoPath = getIntent().getStringExtra("videoUrl");

    Intent intent = getIntent();/*from   ww w .  ja  v  a  2s  .c o m*/
    String intentAction = intent.getAction();
    if (!TextUtils.isEmpty(intentAction)) {
        if (intentAction.equals(Intent.ACTION_VIEW)) {
            mVideoPath = intent.getDataString();
        } else if (intentAction.equals(Intent.ACTION_SEND)) {
            mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                String scheme = mVideoUri.getScheme();
                if (TextUtils.isEmpty(scheme)) {
                    Log.e(TAG, "Null unknown ccheme\n");
                    finish();
                    return;
                }
                if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
                    mVideoPath = mVideoUri.getPath();
                } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
                    Log.e(TAG, "Can not resolve content below Android-ICS\n");
                    finish();
                    return;
                } else {
                    Log.e(TAG, "Unknown scheme " + scheme + "\n");
                    finish();
                    return;
                }
            }
        }
    }

    if (!TextUtils.isEmpty(mVideoPath)) {
        new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
    }

    // init UI
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ActionBar actionBar = getSupportActionBar();
    mMediaController = new AndroidMediaController(this, false);
    mMediaController.setSupportActionBar(actionBar);

    mToastTextView = (TextView) findViewById(R.id.toast_text_view);
    mHudView = (TableLayout) findViewById(R.id.hud_view);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer);

    mDrawerLayout.setScrimColor(Color.TRANSPARENT);

    // init player
    IjkMediaPlayer.loadLibrariesOnce(null);
    IjkMediaPlayer.native_profileBegin("libijkplayer.so");

    mVideoView = (IjkVideoView) findViewById(R.id.video_view);
    mVideoView.setMediaController(mMediaController);
    mVideoView.setHudView(mHudView);

    // 
    mVideoAd = (FrameLayout) findViewById(R.id.video_ad);
    mVideoView.setVideoAd(mVideoAd);
    mVideoView.addVideoAdTask(0, "http://www.pp3.cn/uploads/allimg/111110/15563RI9-7.jpg");
    mVideoView.addVideoAdTask(10000, intent.getStringExtra("videoImg"));
    mVideoView.addVideoAdTask(20000,
            "http://photo.enterdesk.com/2011-2-16/enterdesk.com-1AA0C93EFFA51E6D7EFE1AE7B671951F.jpg");
    mVideoView.addVideoAdTask(15000,
            "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png");

    // prefer mVideoPath
    if (mVideoPath != null)
        mVideoView.setVideoPath(mVideoPath);
    else if (mVideoUri != null)
        mVideoView.setVideoURI(mVideoUri);
    else {
        Log.e(TAG, "Null Data Source\n");
        finish();
        return;
    }
    mVideoView.start();
}

From source file:jp.coe.winkbook.ItemListActivity.java

/**
 * Callback method from {@link ItemListFragment.Callbacks}
 * indicating that the item with the given ID was selected.
 *//*www  .  ja va2 s  .c o  m*/
@Override
public void onItemSelected(File file) {
    Log.d(TAG, "onItemSelected " + file.getName());
    Log.d(TAG, "onItemSelected " + file.getPath());

    if (file.isDirectory()) {
        //????
        Log.d(TAG, "isDirectory");
        Bundle arguments = new Bundle();
        arguments.putParcelable(Intent.EXTRA_STREAM, Uri.fromFile(file));
        ItemListFragment fragment = new ItemListFragment();
        fragment.setArguments(arguments);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        mTitleList.addLast(file.getName());
        toolbar.setTitle((String) mTitleList.getLast());

        getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
                .replace(R.id.frameLayout, fragment).addToBackStack(null).commit();

    } else {

        //??
        Uri fileUri = Uri.fromFile(file);
        Intent detailIntent = new Intent(this, PageActivity.class);
        String path = fileUri.getPath();
        String mime = PageActivity.getMimeType(path);
        Log.d(TAG, "fileUri " + fileUri);
        Log.d(TAG, "mime " + mime);
        detailIntent.setDataAndType(fileUri, mime);
        detailIntent.setAction(android.content.Intent.ACTION_VIEW);
        startActivity(detailIntent);
    }
}

From source file:com.android.shell.BugreportReceiver.java

/**
 * Build {@link Intent} that can be used to share the given bugreport.
 *///from  w  w w . ja va2s  .c  o  m
private static Intent buildSendIntent(Context context, Uri bugreportUri, Uri screenshotUri) {
    final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setType("application/vnd.android.bugreport");

    intent.putExtra(Intent.EXTRA_SUBJECT, bugreportUri.getLastPathSegment());
    intent.putExtra(Intent.EXTRA_TEXT, SystemProperties.get("ro.build.description"));

    final ArrayList<Uri> attachments = Lists.newArrayList(bugreportUri, screenshotUri);
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);

    final Account sendToAccount = findSendToAccount(context);
    if (sendToAccount != null) {
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { sendToAccount.name });
    }

    return intent;
}

From source file:com.dwdesign.tweetings.activity.ImageViewerActivity.java

@Override
public void onClick(final View view) {
    final Uri uri = getIntent().getData();
    switch (view.getId()) {
    case R.id.close: {
        onBackPressed();/*from   w w  w . j a va 2  s .  c  o m*/
        break;
    }
    case R.id.refresh_stop_save: {
        if (!mImageLoaded && !mImageLoading) {
            loadImage();
        } else if (!mImageLoaded && mImageLoading) {
            stopLoading();
        } else if (mImageLoaded) {
            saveImage();
        }
        break;
    }
    case R.id.share: {
        if (uri == null) {
            break;
        }
        final Intent intent = new Intent(Intent.ACTION_SEND);
        final String scheme = uri.getScheme();
        if ("file".equals(scheme)) {
            intent.setType("image/*");
            intent.putExtra(Intent.EXTRA_STREAM, uri);
        } else {
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TEXT, uri.toString());
        }
        startActivity(Intent.createChooser(intent, getString(R.string.share)));
        break;
    }
    case R.id.open_in_browser: {
        if (uri == null) {
            break;
        }
        final String scheme = uri.getScheme();
        if ("http".equals(scheme) || "https".equals(scheme)) {
            final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            try {
                startActivity(intent);
            } catch (final ActivityNotFoundException e) {
                // Ignore.
            }
        }
        break;
    }
    }
}