Example usage for android.content Intent setData

List of usage examples for android.content Intent setData

Introduction

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

Prototype

public @NonNull Intent setData(@Nullable Uri data) 

Source Link

Document

Set the data this intent is operating on.

Usage

From source file:in.shick.diode.reddits.PickSubredditActivity.java

private void returnSubreddit(String subreddit) {
    Intent intent = new Intent();
    subreddit = subreddit.toLowerCase();
    if (!Constants.FRONTPAGE_STRING.equals(subreddit)) {
        subreddit = subreddit.replaceAll("\\s", "");
    }//from  ww w . ja  v a  2s. co  m
    intent.setData(Util.createSubredditUri(subreddit));
    setResult(RESULT_OK, intent);
    finish();
}

From source file:com.g_node.gca.map.MapActivity.java

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

    getActionBar().setIcon(getResources().getDrawable(R.drawable.icon_maps));
    getActionBar().setTitle("Locations Map");

    getActionBar().setDisplayHomeAsUpEnabled(true);

    try {/*from   w w w  .j  ava2 s.c o m*/
        MapsInitializer.initialize(this);
    } catch (GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
    }
    locationMarkers();

    //Lisener for infoWindow to get LAT & LONG of that marker
    supportMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {

        public void onInfoWindowClick(Marker marker) {
            LatLng position = marker.getPosition();
            Log.i(gtag, "Marker Info Clicked - LAT: " + position.latitude + ", LONG: " + position.longitude);

            Intent navigateIntent = new Intent(Intent.ACTION_VIEW);

            String currentLat = String.valueOf(position.latitude);
            String currentLong = String.valueOf(position.longitude);
            String currLabel = marker.getTitle();

            String geoLocation = "geo:0,0?q=" + currentLat + "," + currentLong + "(" + currLabel + ")";
            navigateIntent.setData(Uri.parse(geoLocation));
            startActivity(navigateIntent);

        }
    });

    //adapter for custom info-window - added icon for navigation
    supportMap.setInfoWindowAdapter(new InfoWindowAdapter() {

        @Override
        public View getInfoWindow(Marker arg0) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public View getInfoContents(Marker arg0) {
            // TODO Auto-generated method stub
            // Getting view from the layout file info_window_layout
            View v = getLayoutInflater().inflate(R.layout.info_window_layout, null);

            // Getting reference to the TextView to set title
            TextView note = (TextView) v.findViewById(R.id.note);

            note.setText(arg0.getTitle());

            // Returning the view containing InfoWindow contents
            return v;
        }
    });

}

From source file:cm.aptoide.pt.RemoteInSearch.java

@Override
protected void onListItemClick(ListView l, View v, final int position, long id) {

    super.onListItemClick(l, v, position, id);

    Vector<String> tmp_get = db.getApk(apk_lst.get(position).apkid);

    String tmp_path = this.getString(R.string.icons_path) + apk_lst.get(position).apkid;
    File test_icon = new File(tmp_path);

    LayoutInflater li = LayoutInflater.from(this);
    View view = li.inflate(R.layout.alertscroll, null);
    Builder alrt = new AlertDialog.Builder(this).setView(view);
    final AlertDialog p = alrt.create();
    if (test_icon.exists() && test_icon.length() > 0) {
        p.setIcon(new BitmapDrawable(tmp_path));
    } else {/*from w w  w .ja v a  2s .  co m*/
        p.setIcon(android.R.drawable.sym_def_app_icon);
    }
    p.setTitle(apk_lst.get(position).name);
    TextView t1 = (TextView) view.findViewById(R.id.n11);
    t1.setText(tmp_get.firstElement());
    TextView t2 = (TextView) view.findViewById(R.id.n22);
    t2.setText(tmp_get.get(1));
    TextView t3 = (TextView) view.findViewById(R.id.n33);
    t3.setText(tmp_get.get(2));
    TextView t4 = (TextView) view.findViewById(R.id.n44);
    t4.setText(tmp_get.get(3));
    TextView t5 = (TextView) view.findViewById(R.id.n55);
    String tmpi = db.getDescript(apk_lst.get(position).apkid);
    if (!(tmpi == null)) {
        t5.setText(tmpi);
    } else {
        t5.setText("No info availale on server. Search market by pressing the button below for more info.");
    }

    p.setButton2("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    });
    if (tmp_get.get(2).equalsIgnoreCase("\tno\n")) {
        p.setButton(getString(R.string.install), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                p.dismiss();
                new Thread() {
                    public void run() {
                        String apk_pkg = downloadFile(position);
                        if (apk_pkg == null) {
                            Message msg = new Message();
                            msg.arg1 = 1;
                            download_handler.sendMessage(msg);
                            download_error_handler.sendEmptyMessage(0);
                        } else {
                            installApk(apk_pkg, position);
                        }
                    }
                }.start();
            }
        });
        p.setButton3("Search Market", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                p.dismiss();
                Intent intent = new Intent();
                intent.setAction(android.content.Intent.ACTION_VIEW);
                intent.setData(Uri.parse("market://details?id=" + apk_lst.get(position).apkid));
                startActivity(intent);
            }
        });
    } else {
        p.setButton(getString(R.string.rem), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                String apk_pkg = apk_lst.get(position).apkid;
                removeApk(apk_pkg, position);
            }
        });
        if (apk_lst.get(position).status == 2) {
            p.setButton3(getString(R.string.update), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    p.dismiss();
                    new Thread() {
                        public void run() {
                            String apk_pkg = downloadFile(position);
                            if (apk_pkg == null) {
                                //Toast.makeText(RemoteInSearch.this, "Could not connect to server!", Toast.LENGTH_LONG).show();
                                Message msg = new Message();
                                msg.arg1 = 1;
                                download_handler.sendMessage(msg);
                                download_error_handler.sendEmptyMessage(0);
                            } else {
                                installApk(apk_pkg, position);
                            }
                        }
                    }.start();
                }
            });
        } else {
            p.setButton3("Search Market", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    p.dismiss();
                    Intent intent = new Intent();
                    intent.setAction(android.content.Intent.ACTION_VIEW);
                    intent.setData(Uri.parse("market://details?id=" + apk_lst.get(position).apkid));
                    startActivity(intent);
                }
            });
        }
    }
    p.show();
}

From source file:com.wellsandwhistles.android.redditsp.reddit.prepared.RedditPreparedPost.java

public static void onActionMenuItemSelected(final RedditPreparedPost post, final AppCompatActivity activity,
        final Action action) {

    switch (action) {

    case UPVOTE://from  w w w .j  av a2 s  .  c o m
        post.action(activity, RedditAPI.ACTION_UPVOTE);
        break;

    case DOWNVOTE:
        post.action(activity, RedditAPI.ACTION_DOWNVOTE);
        break;

    case UNVOTE:
        post.action(activity, RedditAPI.ACTION_UNVOTE);
        break;

    case SAVE:
        post.action(activity, RedditAPI.ACTION_SAVE);
        break;

    case UNSAVE:
        post.action(activity, RedditAPI.ACTION_UNSAVE);
        break;

    case HIDE:
        post.action(activity, RedditAPI.ACTION_HIDE);
        break;

    case UNHIDE:
        post.action(activity, RedditAPI.ACTION_UNHIDE);
        break;
    case EDIT:
        final Intent editIntent = new Intent(activity, CommentEditActivity.class);
        editIntent.putExtra("commentIdAndType", post.src.getIdAndType());
        editIntent.putExtra("commentText", StringEscapeUtils.unescapeHtml4(post.src.getRawSelfText()));
        editIntent.putExtra("isSelfPost", true);
        activity.startActivity(editIntent);
        break;

    case DELETE:
        new AlertDialog.Builder(activity).setTitle(R.string.accounts_delete).setMessage(R.string.delete_confirm)
                .setPositiveButton(R.string.action_delete, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int which) {
                        post.action(activity, RedditAPI.ACTION_DELETE);
                    }
                }).setNegativeButton(R.string.dialog_cancel, null).show();
        break;

    case REPORT:

        new AlertDialog.Builder(activity).setTitle(R.string.action_report)
                .setMessage(R.string.action_report_sure)
                .setPositiveButton(R.string.action_report, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int which) {
                        post.action(activity, RedditAPI.ACTION_REPORT);
                        // TODO update the view to show the result
                        // TODO don't forget, this also hides
                    }
                }).setNegativeButton(R.string.dialog_cancel, null).show();

        break;

    case EXTERNAL: {
        final Intent intent = new Intent(Intent.ACTION_VIEW);
        String url = (activity instanceof WebViewActivity) ? ((WebViewActivity) activity).getCurrentUrl()
                : post.src.getUrl();
        intent.setData(Uri.parse(url));
        activity.startActivity(intent);
        break;
    }

    case SELFTEXT_LINKS: {

        final HashSet<String> linksInComment = LinkHandler
                .computeAllLinks(StringEscapeUtils.unescapeHtml4(post.src.getRawSelfText()));

        if (linksInComment.isEmpty()) {
            General.quickToast(activity, R.string.error_toast_no_urls_in_self);

        } else {

            final String[] linksArr = linksInComment.toArray(new String[linksInComment.size()]);

            final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
            builder.setItems(linksArr, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    LinkHandler.onLinkClicked(activity, linksArr[which], false, post.src.getSrc());
                    dialog.dismiss();
                }
            });

            final AlertDialog alert = builder.create();
            alert.setTitle(R.string.action_selftext_links);
            alert.setCanceledOnTouchOutside(true);
            alert.show();
        }

        break;
    }

    case SAVE_IMAGE: {

        ((BaseActivity) activity).requestPermissionWithCallback(Manifest.permission.WRITE_EXTERNAL_STORAGE,
                new SaveImageCallback(activity, post.src.getUrl()));
        break;
    }

    case SHARE: {

        final Intent mailer = new Intent(Intent.ACTION_SEND);
        mailer.setType("text/plain");
        mailer.putExtra(Intent.EXTRA_SUBJECT, post.src.getTitle());
        mailer.putExtra(Intent.EXTRA_TEXT, post.src.getUrl());
        activity.startActivity(Intent.createChooser(mailer, activity.getString(R.string.action_share)));
        break;
    }

    case SHARE_COMMENTS: {

        final boolean shareAsPermalink = PrefsUtility.pref_behaviour_share_permalink(activity,
                PreferenceManager.getDefaultSharedPreferences(activity));

        final Intent mailer = new Intent(Intent.ACTION_SEND);
        mailer.setType("text/plain");
        mailer.putExtra(Intent.EXTRA_SUBJECT, "Comments for " + post.src.getTitle());
        if (shareAsPermalink) {
            mailer.putExtra(Intent.EXTRA_TEXT,
                    Constants.Reddit.getNonAPIUri(post.src.getPermalink()).toString());
        } else {
            mailer.putExtra(Intent.EXTRA_TEXT, Constants.Reddit
                    .getNonAPIUri(Constants.Reddit.PATH_COMMENTS + post.src.getIdAlone()).toString());
        }
        activity.startActivity(
                Intent.createChooser(mailer, activity.getString(R.string.action_share_comments)));
        break;
    }

    case SHARE_IMAGE: {

        ((BaseActivity) activity).requestPermissionWithCallback(Manifest.permission.WRITE_EXTERNAL_STORAGE,
                new ShareImageCallback(activity, post.src.getUrl()));

        break;
    }

    case COPY: {

        ClipboardManager manager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
        manager.setText(post.src.getUrl());
        break;
    }

    case GOTO_SUBREDDIT: {

        try {
            final Intent intent = new Intent(activity, PostListingActivity.class);
            intent.setData(SubredditPostListURL.getSubreddit(post.src.getSubreddit()).generateJsonUri());
            activity.startActivityForResult(intent, 1);

        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            Toast.makeText(activity, R.string.invalid_subreddit_name, Toast.LENGTH_LONG).show();
        }

        break;
    }

    case USER_PROFILE:
        LinkHandler.onLinkClicked(activity, new UserProfileURL(post.src.getAuthor()).toString());
        break;

    case PROPERTIES:
        PostPropertiesDialog.newInstance(post.src.getSrc()).show(activity.getSupportFragmentManager(), null);
        break;

    case COMMENTS:
        ((PostSelectionListener) activity).onPostCommentsSelected(post);

        new Thread() {
            @Override
            public void run() {
                post.markAsRead(activity);
            }
        }.start();

        break;

    case LINK:
        ((PostSelectionListener) activity).onPostSelected(post);
        break;

    case COMMENTS_SWITCH:
        if (!(activity instanceof MainActivity))
            activity.finish();
        ((PostSelectionListener) activity).onPostCommentsSelected(post);
        break;

    case LINK_SWITCH:
        if (!(activity instanceof MainActivity))
            activity.finish();
        ((PostSelectionListener) activity).onPostSelected(post);
        break;

    case ACTION_MENU:
        showActionMenu(activity, post);
        break;

    case REPLY:
        final Intent intent = new Intent(activity, CommentReplyActivity.class);
        intent.putExtra(CommentReplyActivity.PARENT_ID_AND_TYPE_KEY, post.src.getIdAndType());
        intent.putExtra(CommentReplyActivity.PARENT_MARKDOWN_KEY, post.src.getUnescapedSelfText());
        activity.startActivity(intent);
        break;

    case BACK:
        activity.onBackPressed();
        break;

    case PIN:

        try {
            String subredditCanonicalName = RedditSubreddit.getCanonicalName(post.src.getSubreddit());
            List<String> pinnedSubreddits = PrefsUtility.pref_pinned_subreddits(activity,
                    PreferenceManager.getDefaultSharedPreferences(activity));
            if (!pinnedSubreddits.contains(subredditCanonicalName)) {
                PrefsUtility.pref_pinned_subreddits_add(activity,
                        PreferenceManager.getDefaultSharedPreferences(activity), subredditCanonicalName);
            } else {
                Toast.makeText(activity, R.string.mainmenu_toast_pinned, Toast.LENGTH_SHORT).show();
            }
        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            throw new RuntimeException(e);
        }

        break;

    case UNPIN:

        try {
            String subredditCanonicalName = RedditSubreddit.getCanonicalName(post.src.getSubreddit());
            List<String> pinnedSubreddits = PrefsUtility.pref_pinned_subreddits(activity,
                    PreferenceManager.getDefaultSharedPreferences(activity));
            if (pinnedSubreddits.contains(subredditCanonicalName)) {
                PrefsUtility.pref_pinned_subreddits_remove(activity,
                        PreferenceManager.getDefaultSharedPreferences(activity), subredditCanonicalName);
            } else {
                Toast.makeText(activity, R.string.mainmenu_toast_not_pinned, Toast.LENGTH_SHORT).show();
            }
        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            throw new RuntimeException(e);
        }
        break;

    case BLOCK:

        try {
            String subredditCanonicalName = RedditSubreddit.getCanonicalName(post.src.getSubreddit());
            List<String> blockedSubreddits = PrefsUtility.pref_blocked_subreddits(activity,
                    PreferenceManager.getDefaultSharedPreferences(activity));
            if (!blockedSubreddits.contains(subredditCanonicalName)) {
                PrefsUtility.pref_blocked_subreddits_add(activity,
                        PreferenceManager.getDefaultSharedPreferences(activity), subredditCanonicalName);
            } else {
                Toast.makeText(activity, R.string.mainmenu_toast_blocked, Toast.LENGTH_SHORT).show();
            }
        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            throw new RuntimeException(e);
        }
        break;

    case UNBLOCK:

        try {
            String subredditCanonicalName = RedditSubreddit.getCanonicalName(post.src.getSubreddit());
            List<String> blockedSubreddits = PrefsUtility.pref_blocked_subreddits(activity,
                    PreferenceManager.getDefaultSharedPreferences(activity));
            if (blockedSubreddits.contains(subredditCanonicalName)) {
                PrefsUtility.pref_blocked_subreddits_remove(activity,
                        PreferenceManager.getDefaultSharedPreferences(activity), subredditCanonicalName);
            } else {
                Toast.makeText(activity, R.string.mainmenu_toast_not_blocked, Toast.LENGTH_SHORT).show();
            }
        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            throw new RuntimeException(e);
        }
        break;

    case SUBSCRIBE:

        try {
            String subredditCanonicalName = RedditSubreddit.getCanonicalName(post.src.getSubreddit());
            RedditSubredditSubscriptionManager subMan = RedditSubredditSubscriptionManager
                    .getSingleton(activity, RedditAccountManager.getInstance(activity).getDefaultAccount());

            if (subMan.getSubscriptionState(
                    subredditCanonicalName) == RedditSubredditSubscriptionManager.SubredditSubscriptionState.NOT_SUBSCRIBED) {
                subMan.subscribe(subredditCanonicalName, activity);
                Toast.makeText(activity, R.string.options_subscribing, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(activity, R.string.mainmenu_toast_subscribed, Toast.LENGTH_SHORT).show();
            }
        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            throw new RuntimeException(e);
        }
        break;

    case UNSUBSCRIBE:

        try {
            String subredditCanonicalName = RedditSubreddit.getCanonicalName(post.src.getSubreddit());
            RedditSubredditSubscriptionManager subMan = RedditSubredditSubscriptionManager
                    .getSingleton(activity, RedditAccountManager.getInstance(activity).getDefaultAccount());
            if (subMan.getSubscriptionState(
                    subredditCanonicalName) == RedditSubredditSubscriptionManager.SubredditSubscriptionState.SUBSCRIBED) {
                subMan.unsubscribe(subredditCanonicalName, activity);
                Toast.makeText(activity, R.string.options_unsubscribing, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(activity, R.string.mainmenu_toast_not_subscribed, Toast.LENGTH_SHORT).show();
            }
        } catch (RedditSubreddit.InvalidSubredditNameException e) {
            throw new RuntimeException(e);
        }
        break;
    }
}

From source file:fr.bde_eseo.eseomega.lydia.LydiaActivity.java

/**
 * Make an Intent to Lydia App / Web navigator if app is not found
 *///  w  w w  .ja  va2  s  .  c  o  m
void intentToLydia() {

    // Configure and make Lydia Intent
    //String intentUri;
    boolean closeAfter = false;

    // Package Lydia exists ?
    //intentUri = LYDIA_INTENT; // suppose yes

    /*if (Utilities.isPackageExisted(context, LYDIA_PACKAGE)) {
    intentUri = LYDIA_INTENT;
    } else {
    intentUri = MOBILE_URL; // Package doesn't exists : open URL
    closeAfter = true; // @see comment below
    Toast.makeText(context, "Le navigateur va tre ouvert.", Toast.LENGTH_SHORT).show();
    }*/

    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(LYDIA_INTENT));

    PackageManager packageManager = context.getPackageManager();
    if (i.resolveActivity(packageManager) != null) {
        startActivity(i);
    } else { // Package doesn't exists : open URL
        Intent iweb = new Intent();
        closeAfter = true; // @see comment below
        Toast.makeText(context, "Le navigateur va tre ouvert.", Toast.LENGTH_SHORT).show();
        iweb.setData(Uri.parse(MOBILE_URL));
        startActivity(iweb);
    }

    if (closeAfter) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                md.dismiss();
                close(); // prevent app-resume with null orderID
                Toast.makeText(context, "Closing LydiaActivity ...", Toast.LENGTH_SHORT).show();
            }
        }, 1000);
    }
}

From source file:info.guardianproject.otr.app.im.app.WelcomeActivity.java

void handleIntentAPILaunch(Intent srcIntent) {
    Intent intent = new Intent(this, ImUrlActivity.class);
    intent.setAction(srcIntent.getAction());

    if (srcIntent.getData() != null)
        intent.setData(srcIntent.getData());

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (srcIntent.getExtras() != null)
        intent.putExtras(srcIntent.getExtras());
    startActivity(intent);//from w  w w . ja  v a  2s . com

    setIntent(null);
    finish();
}

From source file:com.nbplus.hybrid.BasicWebViewClient.java

/**
 * ??./* w  ww  . j a  v  a 2s .c  o  m*/
 * @param activity : context
 * @param view : ?? 
 */
public BasicWebViewClient(Activity activity, WebView view, String alertTitleString, String confirmTitleString) {
    mWebView = view;
    mContext = activity;

    // This will handle downloading. It requires Gingerbread, though
    mDownloadManager = (DownloadManager) mContext.getSystemService(mContext.DOWNLOAD_SERVICE);
    mWebChromeClient = new BroadcastWebChromeClient();

    // Enable remote debugging via chrome://inspect
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        mWebView.setWebContentsDebuggingEnabled(true);
    }
    mWebView.setWebChromeClient(mWebChromeClient);

    WebSettings webSettings = mWebView.getSettings();
    webSettings.setGeolocationEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setDatabaseEnabled(true);
    // Use WideViewport and Zoom out if there is no viewport defined
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        webSettings.setMediaPlaybackRequiresUserGesture(false);
    }

    // Enable pinch to zoom without the zoom buttons
    webSettings.setBuiltInZoomControls(true);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
        // Hide the zoom controls for HONEYCOMB+
        webSettings.setDisplayZoomControls(false);
    }

    webSettings.setAppCacheEnabled(true);
    mWebView.clearCache(true);
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // Sets whether the WebView should allow third party cookies to be set.
        // Allowing third party cookies is a per WebView policy and can be set differently on different WebView instances.

        // Apps that target KITKAT or below default to allowing third party cookies.
        // Apps targeting LOLLIPOP or later default to disallowing third party cookies.
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptCookie(true);
        cookieManager.setAcceptThirdPartyCookies(mWebView, true);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        mWebView.getSettings().setTextZoom(100);
    }

    if (StringUtils.isEmptyString(alertTitleString)) {
        mAlertTitleString = activity.getString(R.string.default_webview_alert_title);
    } else {
        mAlertTitleString = alertTitleString;
    }

    if (StringUtils.isEmptyString(confirmTitleString)) {
        mConfirmTitleString = activity.getString(R.string.default_webview_confirm_title);
    } else {
        mConfirmTitleString = confirmTitleString;
    }

    mWebView.setDownloadListener(new DownloadListener() {
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype,
                long contentLength) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
            mContext.startActivity(intent);

        }
    });

    Log.d(TAG, ">> user agent = " + mWebView.getSettings().getUserAgentString());
}

From source file:com.example.android.naradaonline.DatagramFragment.java

protected final void sendEmail(DatagramRequest data) {
    if (data.type != DatagramRequestType.SEND_EMAIL) {
        Log.w(TAG, "This datagram is actually of type " + data.type.name());
    }/*w w w.  j  a  v  a  2  s. c o  m*/
    Log.i("Send email", "");

    String[] TO = { data.mEmailTo };
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setData(Uri.parse("mailto:"));
    emailIntent.setType("text/plain");

    emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your Datagram");
    emailIntent.putExtra(Intent.EXTRA_TEXT, data.mEmailBody);

    try {
        startActivity(Intent.createChooser(emailIntent, "Send mail..."));
        Log.i("Finished sending email...", "");
    } catch (android.content.ActivityNotFoundException ex) {
        //            Toast.makeText(MainActivity.this,
        //            "There is no email client installed.", Toast.LENGTH_SHORT).show();
    }
}

From source file:org.loon.framework.android.game.LGameActivity.java

/**
 * ???// w w w .  j  av  a2  s.  c  om
 * 
 * @param url
 */
public void openBrowser(final String url) {
    runOnUiThread(new Runnable() {
        public void run() {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);
        }
    });
}

From source file:com.miz.mizuu.fragments.WebVideoFragment.java

@Override
public void onViewCreated(View v, Bundle savedInstanceState) {
    super.onViewCreated(v, savedInstanceState);

    mProgressBar = (ProgressBar) v.findViewById(R.id.progress);
    if (mVideos.size() > 0)
        mProgressBar.setVisibility(View.GONE); // Hack to remove the ProgressBar on orientation change

    mAdapter = new ImageAdapter(getActivity());

    mGridView = (ObservableGridView) v.findViewById(R.id.gridView);
    mGridView.setClipToPadding(false);/* w w  w  . j av a  2  s .  c  om*/
    mGridView.setAdapter(mAdapter);
    mGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            if (mAdapter.getNumColumns() == 0) {
                final int numColumns = (int) Math
                        .floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing));
                mGridView.setColumnWidth(mImageThumbSize);
                if (numColumns > 0) {
                    mAdapter.setNumColumns(numColumns);
                }
            }
        }
    });
    mGridView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (YouTubeApiServiceUtil.isYouTubeApiServiceAvailable(getActivity())
                    .equals(YouTubeInitializationResult.SUCCESS)) {
                Intent intent = YouTubeStandalonePlayer.createVideoIntent(getActivity(),
                        MizLib.getYouTubeApiKey(getActivity()), mVideos.get(arg2).getId(), 0, false, true);
                startActivity(intent);
            } else {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("http://www.youtube.com/watch?v=" + mVideos.get(arg2).getId()));
                startActivity(intent);
            }
        }
    });
}