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:org.wso2.emm.agent.services.operation.OperationManager.java

/**
 * Open Google Play store application with an application given.
 *
 * @param packageName - Application package name.
 *//*  www  .j  a  v  a  2 s.c o m*/
public void triggerGooglePlayApp(String packageName) {
    if (Constants.DEBUG_MODE_ENABLED) {
        Log.d(TAG, "triggerGooglePlayApp started.");
    }

    try {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setData(Uri.parse(Constants.GOOGLE_PLAY_APP_URI + packageName));
        context.startActivity(intent);
        if (Constants.DEBUG_MODE_ENABLED) {
            Log.d(TAG, "triggerGooglePlayApp called app store.");
        }
    } catch (ActivityNotFoundException e) {
        String error = "App store is not installed. Cannot install the app";
        // Handling the exception when the market place is missing in the device
        Log.e(TAG, error, e);
        Preference.putString(context, context.getResources().getString(R.string.app_install_status),
                context.getResources().getString(R.string.app_status_value_download_failed));
        Preference.putString(context, context.getResources().getString(R.string.app_install_failed_message),
                error);
    }
}

From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java

void showFeedback() {
    Intent intent = new Intent(this, FeedbackActivity.class);
    intent.setData(getIntent().getData());
    startActivity(intent);//ww  w.  j a  v  a  2  s  . c om
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display about dialog to user when invoked from menu option.
 * /* w ww. j  a  va2 s .  com*/
 * @param context
 */
public static void displayAbout(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.about);

    Typeface lightTypeface = ((LauncherApplication) context.getApplicationContext()).getLightTypeface(context);

    TextView aboutTextView = (TextView) dialog.findViewById(R.id.about_text1);
    aboutTextView.setTypeface(lightTypeface);
    aboutTextView.setText(context.getString(R.string.about_version_title, Utils.getVersion(context)));
    aboutTextView.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            context.showCover(false);
            dialog.dismiss();
            Intent intent = new Intent(context, EasterEggActivity.class);
            context.startActivity(intent);
            Analytics.logEvent(Analytics.EASTER_EGG);
            return true;
        }

    });
    TextView copyrightTextView = (TextView) dialog.findViewById(R.id.copyright_text);
    copyrightTextView.setTypeface(lightTypeface);
    TextView feedbackTextView = (TextView) dialog.findViewById(R.id.feedback_text);
    feedbackTextView.setTypeface(lightTypeface);

    ((Button) dialog.findViewById(R.id.button_web)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(context.getString(R.string.about_button_web_url)));
            context.startActivity(intent);
            Analytics.logEvent(Analytics.ABOUT_WEB_SITE);
            context.showCover(false);
            dialog.dismiss();
        }

    });

    ((Button) dialog.findViewById(R.id.button_privacy_policy)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(context.getString(R.string.about_button_privacy_policy_url)));
            context.startActivity(intent);
            Analytics.logEvent(Analytics.ABOUT_PRIVACY_POLICY);
            context.showCover(false);
            dialog.dismiss();
        }

    });
    ((Button) dialog.findViewById(R.id.button_more_apps)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(context.getString(R.string.about_button_more_apps_url)));
            context.startActivity(intent);
            Analytics.logEvent(Analytics.ABOUT_MORE_APPS);
            context.showCover(false);
            dialog.dismiss();
        }

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_ABOUT);
}

From source file:com.example.drugsformarinemammals.General_Info_Drug.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.general_info_drug);
    isStoredInLocal = false;//from  ww w.  j a v a 2  s.c  o m
    fiveLastScreen = false;
    helper = new Handler_Sqlite(this);
    helper.open();
    Bundle extras1 = this.getIntent().getExtras();
    if (extras1 != null) {
        infoBundle = extras1.getStringArrayList("generalInfoDrug");
        fiveLastScreen = extras1.getBoolean("fiveLastScreen");
        if (infoBundle == null)
            isStoredInLocal = true;
        if (!isStoredInLocal) {
            initializeGeneralInfoDrug();
            initializeCodesInformation();
            initializeCodes();
        } else {
            drug_name = extras1.getString("drugName");
            codes = helper.getCodes(drug_name);
            codesInformation = helper.getCodesInformation(drug_name);
        }
        //Title
        TextView drugTitle = (TextView) findViewById(R.id.drugTitle);
        drugTitle.setText(drug_name);
        drugTitle.setTypeface(Typeface.SANS_SERIF);

        //Description 
        LinearLayout borderDescription = new LinearLayout(this);
        borderDescription.setOrientation(LinearLayout.VERTICAL);
        borderDescription
                .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        borderDescription.setBackgroundResource(R.drawable.layout_border);

        TextView description = new TextView(this);
        if (isStoredInLocal)
            description.setText(helper.getDescription(drug_name));
        else
            description.setText(this.description);
        description.setTextSize(18);
        description.setTypeface(Typeface.SANS_SERIF);

        LinearLayout.LayoutParams paramsDescription = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsDescription.leftMargin = 60;
        paramsDescription.rightMargin = 60;
        paramsDescription.topMargin = 20;

        borderDescription.addView(description, borderDescription.getChildCount(), paramsDescription);

        LinearLayout layoutDescription = (LinearLayout) findViewById(R.id.layoutDescription);
        layoutDescription.addView(borderDescription, layoutDescription.getChildCount());

        //Animals
        TextView headerAnimals = (TextView) findViewById(R.id.headerAnimals);
        headerAnimals.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        Button cetaceansButton = (Button) findViewById(R.id.cetaceansButton);
        cetaceansButton.setText("CETACEANS");
        cetaceansButton.setTypeface(Typeface.SANS_SERIF);
        cetaceansButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Cetaceans");
            }
        });

        Button pinnipedsButton = (Button) findViewById(R.id.pinnipedsButton);
        pinnipedsButton.setText("PINNIPEDS");
        pinnipedsButton.setTypeface(Typeface.SANS_SERIF);
        pinnipedsButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                SQLiteDatabase db = helper.open();
                ArrayList<String> families = new ArrayList<String>();
                if (db != null)
                    families = helper.read_animals_family(drug_name, "Pinnipeds");
                if ((families != null && families.size() == 1 && families.get(0).equals(""))
                        || (families != null && families.size() == 0))
                    showDoseInformation(drug_name, "Pinnipeds");
                else
                    showDoseInformationPinnipeds(drug_name, families);
            }
        });

        Button otherButton = (Button) findViewById(R.id.otherButton);
        otherButton.setText("OTHER MM");
        otherButton.setTypeface(Typeface.SANS_SERIF);
        otherButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Other MM");
            }
        });

        //Codes & therapeutic target & anatomical target
        TextView headerATCvetCodes = (TextView) findViewById(R.id.headerATCvetCodes);
        headerATCvetCodes.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        //Action
        TextView headerActionAnatomical = (TextView) findViewById(R.id.headerActionAnatomical);
        headerActionAnatomical.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewAnatomical();
        createBorderAnatomicalGroup();

        TextView headerActionTherapeutic = (TextView) findViewById(R.id.headerActionTherapeutic);
        headerActionTherapeutic.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewTherapeutic();
        createBorderTherapeuticGroup();

        params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.leftMargin = 60;
        params.rightMargin = 60;
        params.topMargin = 20;

        Spinner codesSpinner = (Spinner) findViewById(R.id.codesSpinner);
        SpinnerAdapter adapterCodes = new SpinnerAdapter(this, R.layout.item_spinner, codes);
        adapterCodes.setDropDownViewResource(R.layout.spinner_dropdown_item);
        codesSpinner.setAdapter(adapterCodes);
        codesSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

            public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
                userEntryCode = parent.getSelectedItem().toString();
                int numCodes = codesInformation.size();

                layoutAnatomicalGroup.removeView(borderAnatomicalGroup);
                createBorderAnatomicalGroup();

                boolean founded = false;
                int i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewAnatomical();
                        anatomicalGroup.setText(codesInformation.get(i).getAnatomic_group() + "\n");
                        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }

                layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
                layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
                layoutTherapeuticGroup.removeView(borderTherapeuticGroup);
                createBorderTherapeuticGroup();
                founded = false;
                i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewTherapeutic();
                        therapeuticGroup.setText(codesInformation.get(i).getTherapeutic_group() + "\n");
                        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }
                layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);
                layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());
            }

            public void onNothingSelected(AdapterView<?> arg0) {
            }
        });

        layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
        layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);

        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params);
        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params);

        layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
        layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());

        //Generic Drug
        TextView headerGenericDrug = (TextView) findViewById(R.id.headerGenericDrug);
        headerGenericDrug.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
        boolean isAvalaible = false;
        if (isStoredInLocal)
            isAvalaible = helper.isAvalaible(drug_name);
        else
            isAvalaible = available.equals("Yes");
        if (isAvalaible) {
            ImageView genericDrug = new ImageView(this);
            genericDrug.setImageResource(R.drawable.tick_verde);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        } else {
            Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
            TextView genericDrug = new TextView(this);
            genericDrug.setTypeface(font);
            genericDrug.setText("Nd");
            genericDrug.setTextColor(getResources().getColor(R.color.maroon));
            genericDrug.setTextSize(20);
            DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            int size = metrics.widthPixels;
            int middle = size / 2;
            int quarter = size / 4;
            genericDrug.setTranslationX(middle - quarter);
            genericDrug.setTranslationY(-3);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        }

        //Licenses
        TextView headerLicense = (TextView) findViewById(R.id.headerLicense);
        headerLicense.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        TextView fdaLicense = (TextView) findViewById(R.id.license1);
        Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
        fdaLicense.setTypeface(font);

        String fda;
        if (isStoredInLocal)
            fda = helper.getLicense_FDA(drug_name);
        else
            fda = license_FDA;
        if (fda.equals("Yes")) {
            fdaLicense.setText("Yes");
            fdaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            fdaLicense.setText("Nd");
            fdaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView emaLicense = (TextView) findViewById(R.id.license3);
        emaLicense.setTypeface(font);
        String ema;
        if (isStoredInLocal)
            ema = helper.getLicense_EMA(drug_name);
        else
            ema = license_EMA;
        if (ema.equals("Yes")) {
            emaLicense.setText("Yes");
            emaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            emaLicense.setText("Nd");
            emaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView aempsLicense = (TextView) findViewById(R.id.license2);
        aempsLicense.setTypeface(font);
        String aemps;
        if (isStoredInLocal)
            aemps = helper.getLicense_AEMPS(drug_name);
        else
            aemps = license_AEMPS;
        if (aemps.equals("Yes")) {
            aempsLicense.setText("Yes");
            aempsLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            aempsLicense.setText("Nd");
            aempsLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        ImageButton food_and_drug = (ImageButton) findViewById(R.id.food_and_drug);
        food_and_drug.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.fda.gov/animalveterinary/products/approvedanimaldrugproducts/default.htm"));
                startActivity(intent);
            }
        });

        ImageButton european_medicines_agency = (ImageButton) findViewById(R.id.european_medicines_agency);
        european_medicines_agency.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.ema.europa.eu/ema/index.jsp?curl=pages/medicines/landing/vet_epar_search.jsp&mid=WC0b01ac058001fa1c"));
                startActivity(intent);
            }
        });

        ImageButton logo_aemps = (ImageButton) findViewById(R.id.logo_aemps);
        logo_aemps.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.aemps.gob.es/medicamentosVeterinarios/Med-Vet-autorizados/home.htm"));
                startActivity(intent);
            }

        });

        if (helper.existDrug(drug_name)) {
            int drug_priority = helper.getDrugPriority(drug_name);
            ArrayList<String> sorted_drugs = new ArrayList<String>();
            sorted_drugs.add(0, drug_name);
            for (int i = 1; i < drug_priority; i++) {
                String name = helper.getDrugName(i);
                sorted_drugs.add(i, name);
            }

            for (int i = 0; i < sorted_drugs.size(); i++)
                helper.setDrugPriority(sorted_drugs.get(i), i + 1);
        }

        if (!isStoredInLocal) {
            //Server code
            String[] urls = { "http://formmulary.tk/Android/getDoseInformation.php?drug_name=",
                    "http://formmulary.tk/Android/getGeneralNotesInformation.php?drug_name=" };
            new GetDoseInformation(this).execute(urls);
        }

        helper.close();
    }

}

From source file:io.teak.sdk.Teak.java

@Override
public void onReceive(Context inContext, Intent intent) {
    final Context context = inContext.getApplicationContext();

    if (!Teak.isEnabled()) {
        Log.e(LOG_TAG, "Teak is disabled, ignoring onReceive().");
        return;//w  w  w  .  j  ava  2  s. co  m
    }

    String action = intent.getAction();

    if (GCM_RECEIVE_INTENT_ACTION.equals(action)) {
        final TeakNotification notif = TeakNotification.remoteNotificationFromIntent(context, intent);
        if (notif == null) {
            return;
        }

        // Send Notification Received Metric
        Session.whenUserIdIsReadyRun(new Session.SessionRunnable() {
            @Override
            public void run(Session session) {
                HashMap<String, Object> payload = new HashMap<>();
                payload.put("app_id", session.appConfiguration.appId);
                payload.put("user_id", session.userId());
                payload.put("platform_id", notif.teakNotifId);

                new Request("/notification_received", payload, session).run();
            }
        });
    } else if (action.endsWith(TeakNotification.TEAK_NOTIFICATION_OPENED_INTENT_ACTION_SUFFIX)) {
        Bundle bundle = intent.getExtras();

        // Cancel any updates pending
        TeakNotification.cancel(context, bundle.getInt("platformId"));

        // Launch the app
        if (!bundle.getBoolean("noAutolaunch")) {
            if (Teak.isDebug) {
                Log.d(LOG_TAG,
                        "Notification (" + bundle.getString("teakNotifId") + ") opened, auto-launching app.");
            }
            Intent launchIntent = context.getPackageManager()
                    .getLaunchIntentForPackage(context.getPackageName());
            launchIntent.addCategory("android.intent.category.LAUNCHER");
            launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            launchIntent.putExtras(bundle);
            if (bundle.getString("deepLink") != null) {
                launchIntent.setData(Uri.parse(bundle.getString("deepLink")));
            }
            context.startActivity(launchIntent);
        } else {
            if (Teak.isDebug) {
                Log.d(LOG_TAG, "Notification (" + bundle.getString("teakNotifId")
                        + ") opened, NOT auto-launching app (noAutoLaunch flag present, and set to true).");
            }
        }

        // Send broadcast
        if (Teak.localBroadcastManager != null) {
            Intent broadcastEvent = new Intent(TeakNotification.LAUNCHED_FROM_NOTIFICATION_INTENT);
            broadcastEvent.putExtras(bundle);
            Teak.localBroadcastManager.sendBroadcast(broadcastEvent);
        }
    } else if (action.endsWith(TeakNotification.TEAK_NOTIFICATION_CLEARED_INTENT_ACTION_SUFFIX)) {
        Bundle bundle = intent.getExtras();
        TeakNotification.cancel(context, bundle.getInt("platformId"));
    }

}

From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java

private void displayArtistInfo_bk(JSONObject j) throws JSONException {
    if (imageLoader == null)
        imageLoader = ImageLoader.getInstance();
    if (!imageLoader.isInited())
        imageLoader.init(config);//from   w  w w  . ja  va2s  .  c  o m

    Log.i("musicInfo", "LinkPopUp. displayArtistInfo " + j.toString());

    JSONObject j_artist_info = j.getJSONObject("artist");

    tArtistName.setText(j_artist_info.getString("name"));
    final JSONObject urls = j_artist_info.optJSONObject("urls");
    final JSONArray videos = j_artist_info.optJSONArray("video");
    final JSONArray images = j_artist_info.optJSONArray("images");
    final String fm_image = j.optString("fm_image");
    final JSONArray available_images = new JSONArray();
    ArrayList<String> image_urls = new ArrayList<String>();

    if (fm_image != null) {
        image_urls.add(fm_image);
    }

    Log.i("musicInfo", images.toString());

    if (images != null) {
        for (int i = 0; i < images.length(); i++) {
            JSONObject image = images.getJSONObject(i);
            int width = image.optInt("width", 0);
            int height = image.optInt("height", 0);
            String url = image.optString("url", "");
            Log.i("musicInfo", i + ": " + url);
            if ((width * height > 10000) && (width * height < 100000) && (!url.contains("userserve-ak"))) {
                //if ((width>300&&width<100)&&(height>300&&height<1000)&&(!url.contains("userserve-ak"))) {
                image_urls.add(url);
                Log.i("musicInfo", "Selected: " + url);
                //available_images.put(image);
            }
        }

        int random = (int) (Math.random() * image_urls.size());
        final String f_url = image_urls.get(random);

        //int random = (int) (Math.random() * available_images.length());
        //final JSONObject fImage = available_images.length()>0?available_images.getJSONObject(random > images.length() ? 0 : random):images.getJSONObject(0);

        Log.i("musicInfo",
                "Total image#=" + available_images.length() + " Selected image#=" + random + " " + f_url);

        imageLoader.displayImage(f_url, ArtistImage, new ImageLoadingListener() {
            @Override
            public void onLoadingStarted(String imageUri, View view) {

            }

            @Override
            public void onLoadingFailed(String imageUri, View view, FailReason failReason) {

            }

            @Override
            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

                lLinkList.removeAllViews();
                //String attr = fImage.optJSONObject("license").optString("attribution");
                //tAttribution.setText("Credit. " + ((attr == null) || (attr.contains("n/a")) ? "Unknown" : attr));
                if (urls != null) {
                    String[] jsonName = { "wikipedia_url", "mb_url", "lastfm_url", "official_url",
                            "twitter_url" };
                    for (int i = 0; i < jsonName.length; i++) {
                        if ((urls.optString(jsonName[i]) != null) && (urls.optString(jsonName[i]) != "")) {
                            Log.d("musicinfo", "Link URL: " + urls.optString(jsonName[i]));
                            TextView tv = new TextView(getApplicationContext());
                            tv.setTextSize(11);
                            tv.setPadding(16, 16, 16, 16);
                            tv.setTextColor(Color.LTGRAY);
                            tv.setTypeface(Typeface.SANS_SERIF);
                            tv.setGravity(Gravity.CENTER_VERTICAL);
                            tv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                                    ViewGroup.LayoutParams.WRAP_CONTENT));

                            switch (jsonName[i]) {
                            case "official_url":
                                tv.setText("HOME.");
                                break;
                            case "wikipedia_url":
                                tv.setText("WIKI.");
                                break;
                            case "mb_url":
                                tv.setText("Music Brainz.");
                                break;
                            case "lastfm_url":
                                tv.setText("Last FM.");
                                break;
                            case "twitter_url":
                                tv.setText("Twitter.");
                                break;
                            }

                            try {
                                tv.setTag(urls.getString(jsonName[i]));
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                            tv.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    Intent intent = new Intent();
                                    intent.setAction(Intent.ACTION_VIEW);
                                    intent.addCategory(Intent.CATEGORY_BROWSABLE);
                                    intent.setData(Uri.parse((String) v.getTag()));
                                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                    startActivity(intent);
                                    Toast.makeText(getApplicationContext(), "Open the Link...",
                                            Toast.LENGTH_SHORT).show();
                                    //finish();
                                }
                            });
                            lLinkList.addView(tv);
                        }
                    }
                } else {
                    TextView tv = new TextView(getApplicationContext());
                    tv.setTextSize(11);
                    tv.setPadding(16, 16, 16, 16);
                    tv.setTextColor(Color.LTGRAY);
                    tv.setTypeface(Typeface.SANS_SERIF);
                    tv.setGravity(Gravity.CENTER_VERTICAL);
                    tv.setText("Sorry, No Link Here...");
                    lLinkList.addView(tv);
                }

                if (videos != null) {
                    jVideoArray = videos;
                    mAdapter = new StaggeredViewAdapter(getApplicationContext(),
                            android.R.layout.simple_list_item_1, generateImageData(videos));
                    //if (mData == null) {
                    mData = generateImageData(videos);
                    //}

                    //mAdapter.clear();

                    for (JSONObject data : mData) {
                        mAdapter.add(data);
                    }
                    mGridView.setAdapter(mAdapter);
                } else {

                }

                adjBottomColor(((ImageView) view).getDrawable());
            }

            @Override
            public void onLoadingCancelled(String imageUri, View view) {

            }
        });
    }

}

From source file:com.ximai.savingsmore.save.activity.AddGoodsAcitivyt.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.servise:
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_CALL);
        intent.setData(Uri.parse("tel:" + "58366991"));
        startActivity(intent);/*from  www  . j a  v a  2  s.  c o  m*/
        break;

    case R.id.one_classity:
        PopupWindowFromBottomUtil.shouRange(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                good_one_classify, new PopupWindowFromBottomUtil.Listener2() {
                    @Override
                    public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                        yijifenlei.setTextColor(getResources().getColor(R.color.text_black));
                        yijifenlei.setText(Id1.Name);
                        myProduct.FirstClassId = Id1.Id;
                        oneId = Id1.Id;
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.two_classity:
        if (null != oneId && !TextUtils.isEmpty(oneId)) {
            good_two_classify.clear();
            for (int i = 0; i < list.size(); i++) {
                if (null != list.get(i).Name && null != list.get(i).ParentId && null != list.get(i).Id
                        && list.get(i).ParentId.equals(oneId)) {
                    good_two_classify.add(list.get(i));
                }
            }
            PopupWindowFromBottomUtil.shouRange(
                    AddGoodsAcitivyt.this, LayoutInflater.from(AddGoodsAcitivyt.this)
                            .inflate(R.layout.business_my_center_activity, null),
                    good_two_classify, new PopupWindowFromBottomUtil.Listener2() {
                        @Override
                        public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                            erjifenlei.setTextColor(getResources().getColor(R.color.text_black));
                            erjifenlei.setText(Id1.Name);
                            myProduct.SecondClassId = Id1.Id;
                            popupWindow.dismiss();
                        }
                    });
        } else {
            Toast.makeText(AddGoodsAcitivyt.this, "", Toast.LENGTH_SHORT).show();
        }
        break;
    case R.id.brand_name:
        PopupWindowFromBottomUtil.shouRange(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                brand_list, new PopupWindowFromBottomUtil.Listener2() {
                    @Override
                    public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                        brand.setTextColor(getResources().getColor(R.color.text_black));
                        brand.setText(Id1.Name);
                        myProduct.BrandId = Id1.Id;
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.xingshi_item:
        PopupWindowFromBottomUtil.shouSalesType(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                goodSalesTypes, new PopupWindowFromBottomUtil.Listenrt3() {
                    @Override
                    public void callback(GoodSalesType goodSalesType, PopupWindow popupWindow) {
                        myProduct.PromotionType = goodSalesType.Id;
                        yuan_price.setText("");
                        cuxiao_price.setText("");
                        cuxiao_text.setText("");
                        xingshi.setTextColor(getResources().getColor(R.color.text_black));
                        xingshi.setText(goodSalesType.Value);
                        xingshi_id = goodSalesType.Id;
                        if (goodSalesType.Id.equals("5")) {
                            yuan_price.setText("10");
                            cuxiao_price.setText("10");
                        } else if (goodSalesType.Id.equals("6")) {
                            yuan_price.setText("1");
                            cuxiao_price.setText("1");
                        } else if (goodSalesType.Id.equals("11")) {
                            yuan_price.setText("0");
                            cuxiao_price.setText("0");
                        } else if (goodSalesType.Id.equals("2")) {
                            cuxiao_text.setText("N?N");

                        }
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.dizhi_item:
        PopupWindowFromBottomUtil.showAddress(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                list, new PopupWindowFromBottomUtil.Listenre1() {
                    @Override
                    public void callBack(String Id1, String Id2, String Id3, String content,
                            PopupWindow popupWindow) {
                        myProduct.ProvinceId = Id1;
                        myProduct.CityId = Id2;
                        myProduct.AreaId = Id3;
                        dizhi.setTextColor(getResources().getColor(R.color.text_black));
                        dizhi.setText(content);
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.start_time_item:
        UsePicker.showAll(AddGoodsAcitivyt.this, new UsePicker.CallBack() {
            @Override
            public void callBack(String time) {
                SimpleDateFormat dd = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                Date date1 = null;
                try {
                    date1 = dd.parse(time);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                Long time1 = date1.getTime();
                Date dt = new Date();
                Long now = dt.getTime();
                if (now > time1) {
                    Toast.makeText(AddGoodsAcitivyt.this, "??",
                            Toast.LENGTH_SHORT).show();
                } else {
                    start_date = time;
                    myProduct.StartTime = time;
                    start.setTextColor(getResources().getColor(R.color.text_black));
                    start.setText(time);
                }
            }
        }, start.getText().toString());
        break;
    case R.id.end_time_item:
        UsePicker.showAll(AddGoodsAcitivyt.this, new UsePicker.CallBack() {
            @Override
            public void callBack(String time) {
                SimpleDateFormat dd = new SimpleDateFormat("yyyy-MM-dd");

                try {
                    Date date1 = dd.parse(start_date);
                    Date date2 = dd.parse(time);
                    Long time1 = date1.getTime();
                    Long time2 = date2.getTime();
                    if ((time2 > time1)) {
                        myProduct.EndTime = time;
                        end.setTextColor(getResources().getColor(R.color.text_black));
                        end.setText(time);
                    } else {
                        Toast.makeText(AddGoodsAcitivyt.this, "??",
                                Toast.LENGTH_SHORT).show();
                    }
                } catch (ParseException e) {
                    e.printStackTrace();
                }

            }
        }, end.getText().toString());
        break;
    case R.id.danwei_item:
        PopupWindowFromBottomUtil.shouRange(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                danwei_list, new PopupWindowFromBottomUtil.Listener2() {
                    @Override
                    public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                        myProduct.UnitId = Id1.Id;
                        danwei.setTextColor(getResources().getColor(R.color.text_black));
                        danwei.setText(Id1.Name);
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.bizhong_item:
        PopupWindowFromBottomUtil.shouRange(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                bizhong_list, new PopupWindowFromBottomUtil.Listener2() {
                    @Override
                    public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                        myProduct.CurrencyId = Id1.Id;
                        bizhong.setTextColor(getResources().getColor(R.color.text_black));
                        bizhong.setText(Id1.Name);
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.fapiao_item:
        PopupWindowFromBottomUtil.shouRange(AddGoodsAcitivyt.this,
                LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.business_my_center_activity, null),
                fapiao_list, new PopupWindowFromBottomUtil.Listener2() {
                    @Override
                    public void callBack(BaseMessage Id1, String content, PopupWindow popupWindow) {
                        myProduct.InvoiceId = Id1.Id;
                        fapiao.setTextColor(getResources().getColor(R.color.text_black));
                        fapiao.setText(Id1.Name);
                        popupWindow.dismiss();
                    }
                });
        break;
    case R.id.btnCancel:
        setIconWindow.dismiss();
        break;
    case R.id.btnCamera:
        openCamera();
        setIconWindow.dismiss();
        break;
    case R.id.btnAlbum:
        openAlbum();
        setIconWindow.dismiss();
        break;
    case R.id.fabu:
        myProduct.Name = my_name.getText().toString();
        myProduct.Name = product_name.getText().toString();
        myProduct.Number = product_bianhao.getText().toString();
        myProduct.Address = xiangxi_address.getText().toString();
        myProduct.OriginalPrice = yuan_price.getText().toString();
        myProduct.Price = cuxiao_price.getText().toString();
        myProduct.Introduction = explain.getText().toString();
        myProduct.Description = explain.getText().toString();
        myProduct.Images = images;
        if (myProduct.Images.size() > 0 && null != myProduct.Name && null != myProduct.CityId
                && null != myProduct.InvoiceId && null != myProduct.Address && null != myProduct.AreaId
                && null != myProduct.BrandId && null != myProduct.CurrencyId && null != myProduct.CityId
                && null != myProduct.Description && null != myProduct.EndTime && null != myProduct.Description
                && null != myProduct.FirstClassId && null != myProduct.SecondClassId
                && null != myProduct.Description) {
            saveMyProduct(myProduct);
        } else {
            Toast.makeText(AddGoodsAcitivyt.this, "?", Toast.LENGTH_SHORT).show();
        }

        break;

    }
}

From source file:nf.frex.android.FrexActivity.java

private boolean tryReadingFrexDocIntent(Intent intent) {
    if (intent != null) {
        Uri data = intent.getData();//from   w ww  .  j a  v a  2 s.  c  om
        if (data != null) {
            try {
                readFrexDoc(data);
                return true;
            } finally {
                intent.setData(null);
            }
        }
    }
    return false;
}

From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java

@Override
public void onCreate(Bundle saveInstanceState) {
    super.onCreate(saveInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    Bundle b = getIntent().getExtras();//from  ww  w  .  j  a va2  s  .c om

    SharedPreferences prefs = getSharedPreferences("settings", MODE_PRIVATE);

    imageOptions = new DisplayImageOptions.Builder().cacheInMemory(false).cacheOnDisk(true)
            .bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.EXACTLY)
            .showImageOnLoading(R.drawable.connecting_anim).build();
    config = new ImageLoaderConfiguration.Builder(getApplicationContext()).diskCacheExtraOptions(480, 320, null)
            .defaultDisplayImageOptions(imageOptions).build();

    if (imageLoader == null)
        imageLoader = ImageLoader.getInstance();
    if (!imageLoader.isInited())
        imageLoader.init(config);

    setContentView(R.layout.link_dialog);

    imageFrame = (FrameLayout) findViewById(R.id.image_frame);
    iBottomPanel = (ImageView) findViewById(R.id.bottom_panel);

    lArtistLink = (RelativeLayout) findViewById(R.id.l_artist_link);

    bPopUpClose = (ImageView) findViewById(R.id.b_popup_close);
    bPopUpClose.setOnClickListener(this);

    tEchoNest = (TextView) findViewById(R.id.t_echo_nest);
    tAttribution = (TextView) findViewById(R.id.t_attribution);

    tArtistName = (TextView) findViewById(R.id.t_artist_name);
    tArtistName.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                //isMove = false;
                mTouchX = event.getRawX();
                mTouchY = event.getRawY();
                break;

            case MotionEvent.ACTION_UP:
                //Log.i("musicInfo", "ACTION_UP! TouchY:" + mTouchY + " UpY: " + event.getRawY() + " Move: " + (mTouchY - event.getRawY()));
                int RawY = (int) event.getRawY();
                int dY = (int) (mTouchY - event.getRawY());
                if (dY > 200) {
                    imageLoader.resume();
                    //Log.i("musicInfo", "mGridView TOP = " + mGridView.getTop() + " mGridView TransitionY =" + mGridView.getTranslationY());
                    while (mGridView.getTranslationY() > tArtistName.getHeight()) {
                        //Log.i("musicInfo", "Moving UP! mGridView: " + mGridView.getTranslationY() + " tArtistName: " + tArtistName.getTranslationY());
                        mGridView.setTranslationY(mGridView.getTranslationY() - 1);
                        tArtistName.setTranslationY(tArtistName.getTranslationY() - 1);

                    }
                } else if (dY > 5 && dY <= 200 || (dY <= 5 && tArtistName.getTranslationY() < 0)) {
                    while (tArtistName.getTranslationY() < 0) {
                        //Log.i("musicInfo", "Moving DOWN! mGridView: " + mGridView.getTranslationY() + " tArtistName: " + tArtistName.getTranslationY());
                        mGridView.setTranslationY(mGridView.getTranslationY() + 1);
                        tArtistName.setTranslationY(tArtistName.getTranslationY() + 1);
                    }
                    imageLoader.pause();
                }
                break;

            case MotionEvent.ACTION_MOVE:
                //isMove = true;

                //int top = tArtistName.getTop();
                //int bottom = tArtistName.getBottom();
                //int left = tArtistName.getLeft();
                //int right = tArtistName.getRight();

                int x = (int) (event.getRawX() - mTouchX);
                int y = (int) (event.getRawY() - mTouchY);

                final int num = 5;
                if (y > -num && y < num) {
                    //isMove = false;
                    break;
                } else if (y > 0) {

                } else {
                    imageFrame.bringChildToFront(mGridView);
                    tArtistName.setTranslationY((float) y);
                    mGridView.setTranslationY((float) (SGVtransition + y));

                    //Log.i("musicInfo", String.format("T: %d, B: %d", mGridView.getTop(), mGridView.getBottom()));

                }

                break;
            }
            return true;
        }
    });

    ArtistImage = (ImageView) findViewById(R.id.artist_image);

    lLinkList = (LinearLayout) findViewById(R.id.l_link_list);

    mGridView = (StaggeredGridView) findViewById(R.id.SG_view);

    SGVtransition = 900;

    mGridView.setTranslationY(SGVtransition);

    JSONObject artist_info = null;
    try {
        artist_info = new JSONObject(b.getString("artist_info"));
        Log.i("musicInfo", "LinkPopUp. OnCreate" + artist_info.toString());
        displayArtistInfo(artist_info);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    if (artist_info != null)
        jArtists.put(artist_info);
    if (prefs.getBoolean("SimilarOn", false)) {
        getSimilarArtistsInfo((String) tArtistName.getText());
        ArtistImage.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {

                switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    //isMove = false;
                    mTouchX = event.getRawX();
                    mTouchY = event.getRawY();
                    break;

                case MotionEvent.ACTION_UP:
                    //Log.i("musicInfo", "ACTION_UP! TouchY:" + mTouchY + " UpY: " + event.getRawY() + " Move: " + (mTouchY - event.getRawY()));
                    int dX = (int) (mTouchX - event.getRawX());
                    if (dX > 5) {
                        if (jArtists.length() > 1) {
                            imageLoader.stop();
                            try {
                                if (artistNum == 0) {
                                    artistNum = jArtists.length() - 1;
                                } else {
                                    artistNum--;
                                }

                                displayArtistInfo(jArtists.getJSONObject(artistNum));
                                imageLoader.resume();

                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                        }

                    } else if (dX < -5) {
                        if (jArtists.length() > 1) {
                            imageLoader.stop();
                            try {
                                if (artistNum == jArtists.length() - 1) {
                                    artistNum = 0;
                                } else {
                                    artistNum++;
                                }
                                displayArtistInfo(jArtists.getJSONObject(artistNum));
                                imageLoader.resume();
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                        }

                    }

                    break;

                case MotionEvent.ACTION_MOVE:

                    break;
                }

                return true;
            }
        });
    }

    mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            //Log.d("musicInfo", "SGV onScrollStateChanged:" + scrollState);
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            //Log.d("musicInfo", "SGV onScroll firstVisibleItem:" + firstVisibleItem + " visibleItemCount:" + visibleItemCount + " totalItemCount:" + totalItemCount);
            // our handling
            if (!mHasRequestedMore) {
                int lastInScreen = firstVisibleItem + visibleItemCount;
                if (lastInScreen >= totalItemCount) {
                    //Log.d("musicInfo", "SGV onScroll lastInScreen - so load more");
                    mHasRequestedMore = true;
                    onLoadMoreItems();
                }
            }
        }

        private void onLoadMoreItems() {
            if (jVideoArray == null)
                return;
            final ArrayList<JSONObject> sampleData = generateImageData(jVideoArray);
            for (JSONObject data : sampleData) {
                mAdapter.add(data);
            }
            // stash all the data in our backing store
            mData.addAll(sampleData);
            // notify the adapter that we can update now
            mAdapter.notifyDataSetChanged();
            mHasRequestedMore = false;
        }
    });

    mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(getApplicationContext(), "Open the Video...", Toast.LENGTH_SHORT).show();
            StaggeredViewAdapter.ViewHolder vh = (StaggeredViewAdapter.ViewHolder) view.getTag();

            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            intent.setData(Uri.parse((String) vh.url));
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            //finish();

        }

    });

    //int[] lArtistLinkPosition = new int[2];
    //int[] tArtistNamePosition = new int[2];

    //lArtistLink.getLocationOnScreen(lArtistLinkPosition);
    //tArtistName.getLocationOnScreen(tArtistNamePosition);

    //Log.d("musicInfo", "SGV transition = " + SGVtransition);
}

From source file:com.intel.xdk.device.Device.java

public void launchExternal(String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));
    activity.startActivity(intent);
}