Example usage for android.content Intent ACTION_VIEW

List of usage examples for android.content Intent ACTION_VIEW

Introduction

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

Prototype

String ACTION_VIEW

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

Click Source Link

Document

Activity Action: Display the data to the user.

Usage

From source file:com.onebus.zxing.decoding.CaptureActivityHandler.java

@Override
public void handleMessage(Message message) {
    switch (message.what) {
    case R.id.auto_focus:
        //Log.d(TAG, "Got auto-focus message");
        // When one auto focus pass finishes, start another. This is the closest thing to
        // continuous AF. It does seem to hunt a bit, but I'm not sure what else to do.
        if (state == State.PREVIEW) {
            CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
        }//from  www.  j a  va 2s  .com
        break;
    case R.id.restart_preview:
        Log.d(TAG, "Got restart preview message");
        restartPreviewAndDecode();
        break;
    case R.id.decode_succeeded:
        Log.d(TAG, "Got decode succeeded message");
        state = State.SUCCESS;
        Bundle bundle = message.getData();

        /***********************************************************************/
        Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//

        try {
            activity.handleDecode((Result) message.obj, barcode);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } //?        /***********************************************************************/
        break;
    case R.id.decode_failed:
        // We're decoding as fast as possible, so when one decode fails, start another.
        state = State.PREVIEW;
        CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
        break;
    case R.id.return_scan_result:
        Log.d(TAG, "Got return scan result message");
        activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
        activity.finish();
        break;
    case R.id.launch_product_query:
        Log.d(TAG, "Got product query message");
        String url = (String) message.obj;
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        activity.startActivity(intent);
        break;
    }
}

From source file:net.reichholf.dreamdroid.activities.ShareActivity.java

@SuppressWarnings("deprecation")
private void playOnDream(Profile p) {
    String url = null;//  w w w  . java  2 s .  co m
    Intent i = getIntent();
    Bundle extras = i.getExtras();
    mShc = SimpleHttpClient.getInstance(p);
    if (Intent.ACTION_SEND.equals(i.getAction()))
        url = extras.getString(Intent.EXTRA_TEXT);
    else if (Intent.ACTION_VIEW.equals(i.getAction()))
        url = i.getDataString();

    if (url != null) {
        Log.i(LOG_TAG, url);
        Log.i(LOG_TAG, p.getHost());

        String time = DateFormat.getDateFormat(this).format(new Date());
        String title = getString(R.string.sent_from_dreamdroid, time);
        if (extras != null) {
            // semperVidLinks sends "artist" and "song" attributes for the
            // youtube video titles
            String song = extras.getString("song");
            if (song != null) {
                String artist = extras.getString("artist");
                if (artist != null)
                    title = artist + " - " + song;
            } else {
                String tmp = extras.getString("title");
                if (tmp != null)
                    title = tmp;
            }
        }
        mTitle = title;

        url = URLEncoder.encode(url).replace("+", "%20");
        title = URLEncoder.encode(title).replace("+", "%20");

        String ref = "4097:0:1:0:0:0:0:0:0:0:" + url + ":" + title;
        Log.i(LOG_TAG, ref);
        ArrayList<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("file", ref));
        execSimpleResultTask(params);
    } else {
        finish();
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.InviteToGroupObj.java

@Override
public void activate(Context context, SignedObj obj) {
    JSONObject content = obj.getJson();//from  www.  j  a  va2 s.com
    String groupName = content.optString(GROUP_NAME);
    Uri dynUpdateUri = Uri.parse(content.optString(DYN_UPDATE_URI));

    Intent launch = new Intent(Intent.ACTION_VIEW);
    launch.setData(dynUpdateUri);
    launch.putExtra("type", TYPE);
    launch.putExtra("creator", false);
    launch.putExtra(GROUP_NAME, groupName);
    launch.putExtra(DYN_UPDATE_URI, dynUpdateUri);
    context.startActivity(launch);
}

From source file:com.codebutler.farebot.fragments.CardsFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    Uri uri = ContentUris.withAppendedId(CardProvider.CONTENT_URI_CARD, id);
    startActivity(new Intent(Intent.ACTION_VIEW, uri));

}

From source file:com.appnexus.opensdk.ANJAMImplementation.java

private static void callExternalBrowser(WebView webView, Uri uri) {
    String urlParam = uri.getQueryParameter("url");

    if ((webView.getContext() == null) || (urlParam == null) || (!urlParam.startsWith("http"))) {
        return;//from  www  . jav  a2s  .  co m
    }
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Uri.decode(urlParam)));
        webView.getContext().startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(webView.getContext(), R.string.action_cant_be_completed, Toast.LENGTH_SHORT).show();
    }
}

From source file:com.hybris.mobile.app.commerce.fragment.OrderDetailFragment.java

@Override
public void onResume() {
    super.onResume();

    mComingFromSearch = getActivity().getIntent().getExtras() != null
            && getActivity().getIntent().getExtras().getBoolean(IntentConstants.ORDER_FROM_SEARCH);

    QueryOrder queryOrder = new QueryOrder();

    Intent intent = getActivity().getIntent();
    if (intent.hasExtra(IntentConstants.ORDER_CODE)) {
        queryOrder.setCode(getActivity().getIntent().getStringExtra(IntentConstants.ORDER_CODE));
    } else if (StringUtils.equals(intent.getAction(), Intent.ACTION_VIEW)) {
        queryOrder.setCode(RegexUtils.getOrderCode(intent.getDataString()));
    }//from w ww.ja  va 2s .  co  m

    // Getting the order
    CommerceApplication.getContentServiceHelper().getOrder(this, mOrderRequestId, queryOrder, null, false, null,
            new OnRequestListener() {

                @Override
                public void beforeRequest() { //hide when loading

                    UIUtils.showLoadingActionBar(getActivity(), true);
                    getView().setVisibility(View.INVISIBLE);
                }

                @Override
                public void afterRequestBeforeResponse() {

                }

                @Override
                public void afterRequest(boolean isDataSynced) {
                    getView().setVisibility(View.VISIBLE);
                    UIUtils.showLoadingActionBar(getActivity(), false);
                }
            });
}

From source file:jahirfiquitiva.iconshowcase.services.MuzeiArtSourceService.java

private void setImageForMuzei(String name, String author, String url) {
    publishArtwork(new Artwork.Builder().title(name).byline(author).imageUri(Uri.parse(url))
            .viewIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(url))).build());
    scheduleUpdate(System.currentTimeMillis() + mPrefs.getRotateTime());
}

From source file:com.mycelium.wallet.simplex.SimplexMainActivity.java

private void redirectWebView(String siteUrl, int responseCode, String signedData, String signature) {
    Log.d("Simplex", "RedirectWebView...");
    String fullSiteUrl = String.format("%s?nonce=%s&wallet_address=%s&lvlcode=%s&lvlsignedData=%s&signature=%s",
            siteUrl, _simplexNonce.simplexNonce, _walletAddress, responseCode, signedData, signature);
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(fullSiteUrl));
    Log.d("webview post nonce", String.valueOf(_simplexNonce.simplexNonce));
    Log.d("webview post wallet", _walletAddress);
    Log.d("webview post lvlCode", String.valueOf(responseCode));
    Log.d("webview post signedData", signedData);
    Log.d("webview post signature", signature);
    setLayout(SimplexUITypes.WebView);/*from   ww w .  jav  a 2 s.c  om*/
    startActivity(browserIntent);

}

From source file:it.scoppelletti.mobilepower.app.AppUtils.java

/**
 * Istanzia l&rsquo;intento per l&rsquo;acquisto di un&rsquo;applicazione.
 * //from  w ww . jav a  2 s . c  o m
 * @param  ctx Contesto.
 * @return     Intento.
 */
public static Intent newBuyIntent(Context ctx) {
    String pkgName;
    Intent intent;
    Uri.Builder uriBuilder;

    if (ctx == null) {
        throw new NullPointerException("Argument ctx is null.");
    }

    pkgName = AppUtils.getFullPackageName(ctx, false);

    uriBuilder = new Uri.Builder();
    uriBuilder.scheme("market").authority("details").appendQueryParameter("id", pkgName);
    intent = new Intent(Intent.ACTION_VIEW, uriBuilder.build());

    return intent;
}

From source file:com.thedamfr.facebook_dashclock_ext.ExampleExtension.java

@Override
protected void onUpdateData(int reason) {
    Session fbSession = Session.getActiveSession();
    if (fbSession == null) {
        Resources resources = this.getResources();
        AssetManager assetManager = resources.getAssets();
        Properties properties = new Properties();
        // Read from the /assets directory
        try {//from w  w  w.  j a v a2s . c om
            InputStream inputStream = assetManager.open("facebook.properties");
            properties.load(inputStream);
            System.out.println("The properties are now loaded");
            //System.out.println("properties: " + properties);
        } catch (IOException e) {
            System.err.println("Failed to open facebook property file");
            e.printStackTrace();
        }

        Session session = new Session.Builder(this).setApplicationId(properties.getProperty("app_id", ""))
                .build();
        Session.setActiveSession(session);
        fbSession = session;
    }
    if (fbSession != null && !fbSession.isOpened()) {
        Intent intent = new Intent(this, RefreshSessionActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }
    if (fbSession.isOpened()) {
        Request notificationsRequest = Request.newGraphPathRequest(fbSession, "me/notifications",
                new Request.Callback() {

                    @Override
                    public void onCompleted(Response response) {
                        GraphObject object = response.getGraphObject();
                        if (object != null) {
                            JSONArray notifications = (JSONArray) object.getProperty("data");
                            if (notifications.length() >= 1) {
                                // Publish the extension data update.
                                String title = null;
                                String link = null;
                                try {
                                    title = ((JSONObject) notifications.get(0)).getString("title");
                                    link = ((JSONObject) notifications.get(0)).getString("link");
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                    title = "Can't read title";
                                }
                                publishUpdate(new ExtensionData().visible(true).icon(R.drawable.icon)
                                        .status("New Content")
                                        .expandedTitle(notifications.length() + "  notifications")
                                        .expandedBody(title)
                                        .clickIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(link))));

                            } else {
                                publishUpdate(new ExtensionData().visible(false).status("No Content"));
                            }
                        } else {
                            publishUpdate(new ExtensionData().visible(false).status("No Content"));
                        }

                    }
                });

        notificationsRequest.executeAsync();
    }

}