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:com.andrewshu.android.reddit.mail.InboxListActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case Constants.DIALOG_COMMENT_CLICK:
        Intent i = new Intent(getApplicationContext(), CommentsListActivity.class);
        i.setData(Util.createCommentUri(mVoteTargetThingInfo, 0));
        i.putExtra(Constants.EXTRA_SUBREDDIT, mVoteTargetThingInfo.getSubreddit());
        i.putExtra(Constants.EXTRA_TITLE, mVoteTargetThingInfo.getTitle());
        startActivity(i);/*from  w  ww .  j a  v a 2  s. co  m*/
        return true;
    case Constants.DIALOG_MESSAGE_CLICK:
        showDialog(Constants.DIALOG_REPLY);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.phonegap.bossbolo.plugin.inappbrowser.InAppBrowser.java

/**
 * Executes the request and returns PluginResult.
 *
 * @param action        The action to execute.
 * @param args          JSONArry of arguments for the plugin.
 * @param callbackId    The callback id used when calling back into JavaScript.
 * @return              A PluginResult object with a status and message.
 *///from w ww . ja v a  2s .  c o  m
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext)
        throws JSONException {
    if (action.equals("open")) {
        this.callbackContext = callbackContext;
        final String url = args.getString(0);
        String t = args.optString(1);
        if (t == null || t.equals("") || t.equals(NULL)) {
            t = SELF;
        }
        final String target = t;
        final HashMap<String, Boolean> features = parseFeature(args.optString(2));

        String h = args.optString(3);
        if (h == null || h.equals("") || h.equals(NULL)) {
            h = url;
        }
        final String header = h;

        Log.d(LOG_TAG, "target = " + target);

        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                String result = "";
                // SELF
                if (SELF.equals(target)) {
                    Log.d(LOG_TAG, "in self");
                    /* This code exists for compatibility between 3.x and 4.x versions of Cordova.
                     * Previously the Config class had a static method, isUrlWhitelisted(). That
                     * responsibility has been moved to the plugins, with an aggregating method in
                     * PluginManager.
                     */
                    Boolean shouldAllowNavigation = null;
                    if (url.startsWith("javascript:")) {
                        shouldAllowNavigation = true;
                    }
                    if (shouldAllowNavigation == null) {
                        try {
                            Method iuw = Config.class.getMethod("isUrlWhiteListed", String.class);
                            shouldAllowNavigation = (Boolean) iuw.invoke(null, url);
                        } catch (NoSuchMethodException e) {
                        } catch (IllegalAccessException e) {
                        } catch (InvocationTargetException e) {
                        }
                    }
                    if (shouldAllowNavigation == null) {
                        try {
                            Method gpm = webView.getClass().getMethod("getPluginManager");
                            PluginManager pm = (PluginManager) gpm.invoke(webView);
                            Method san = pm.getClass().getMethod("shouldAllowNavigation", String.class);
                            shouldAllowNavigation = (Boolean) san.invoke(pm, url);
                        } catch (NoSuchMethodException e) {
                        } catch (IllegalAccessException e) {
                        } catch (InvocationTargetException e) {
                        }
                    }
                    // load in webview
                    if (Boolean.TRUE.equals(shouldAllowNavigation)) {
                        Log.d(LOG_TAG, "loading in webview");
                        webView.loadUrl(url);
                    }
                    //Load the dialer
                    else if (url.startsWith(WebView.SCHEME_TEL)) {
                        try {
                            Log.d(LOG_TAG, "loading in dialer");
                            Intent intent = new Intent(Intent.ACTION_DIAL);
                            intent.setData(Uri.parse(url));
                            cordova.getActivity().startActivity(intent);
                        } catch (android.content.ActivityNotFoundException e) {
                            LOG.e(LOG_TAG, "Error dialing " + url + ": " + e.toString());
                        }
                    }
                    // load in InAppBrowser
                    else {
                        Log.d(LOG_TAG, "loading in InAppBrowser");
                        result = showWebPage(url, features, header);
                    }
                }
                // SYSTEM
                else if (SYSTEM.equals(target)) {
                    Log.d(LOG_TAG, "in system");
                    result = openExternal(url);
                }
                // BLANK - or anything else
                else {
                    Log.d(LOG_TAG, "in blank");
                    result = showWebPage(url, features, header);
                }

                PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, result);
                pluginResult.setKeepCallback(true);
                callbackContext.sendPluginResult(pluginResult);
            }
        });
    } else if (action.equals("close")) {
        closeDialog();
    } else if (action.equals("injectScriptCode")) {
        String jsWrapper = null;
        if (args.getBoolean(1)) {
            jsWrapper = String.format("prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')",
                    callbackContext.getCallbackId());
        }
        injectDeferredObject(args.getString(0), jsWrapper);
    } else if (action.equals("injectScriptFile")) {
        String jsWrapper;
        if (args.getBoolean(1)) {
            jsWrapper = String.format(
                    "(function(d) { var c = d.createElement('script'); c.src = %%s; c.onload = function() { prompt('', 'gap-iab://%s'); }; d.body.appendChild(c); })(document)",
                    callbackContext.getCallbackId());
        } else {
            jsWrapper = "(function(d) { var c = d.createElement('script'); c.src = %s; d.body.appendChild(c); })(document)";
        }
        injectDeferredObject(args.getString(0), jsWrapper);
    } else if (action.equals("injectStyleCode")) {
        String jsWrapper;
        if (args.getBoolean(1)) {
            jsWrapper = String.format(
                    "(function(d) { var c = d.createElement('style'); c.innerHTML = %%s; d.body.appendChild(c); prompt('', 'gap-iab://%s');})(document)",
                    callbackContext.getCallbackId());
        } else {
            jsWrapper = "(function(d) { var c = d.createElement('style'); c.innerHTML = %s; d.body.appendChild(c); })(document)";
        }
        injectDeferredObject(args.getString(0), jsWrapper);
    } else if (action.equals("injectStyleFile")) {
        String jsWrapper;
        if (args.getBoolean(1)) {
            jsWrapper = String.format(
                    "(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %%s; d.head.appendChild(c); prompt('', 'gap-iab://%s');})(document)",
                    callbackContext.getCallbackId());
        } else {
            jsWrapper = "(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %s; d.head.appendChild(c); })(document)";
        }
        injectDeferredObject(args.getString(0), jsWrapper);
    } else if (action.equals("show")) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                dialog.show();
            }
        });
        PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
        pluginResult.setKeepCallback(true);
        this.callbackContext.sendPluginResult(pluginResult);
    } else {
        return false;
    }
    return true;
}

From source file:babybear.akbquiz.ConfigActivity.java

/**
 * ?// w ww  .  j  a  va 2s.c  om
 */
private void init() {

    ToggleButton bgm_toggle = (ToggleButton) findViewById(R.id.bgm_switch);
    ToggleButton sound_toggle = (ToggleButton) findViewById(R.id.sound_switch);
    ToggleButton vibration_toggle = (ToggleButton) findViewById(R.id.config_vibration_switch);
    SeekBar bgm_vol = (SeekBar) findViewById(R.id.bgm_volume);
    SeekBar sound_vol = (SeekBar) findViewById(R.id.sound_volume);
    Button config_playlist = (Button) findViewById(R.id.config_playlist);

    bgm_toggle.setChecked(sp_cfg.getBoolean(Database.KEY_switch_bg, true));
    sound_toggle.setChecked(sp_cfg.getBoolean(Database.KEY_switch_sound, true));
    vibration_toggle.setChecked(sp_cfg.getBoolean(Database.KEY_switch_vibration, true));
    bgm_vol.setProgress(sp_cfg.getInt(Database.KEY_vol_bg, 10));
    sound_vol.setProgress(sp_cfg.getInt(Database.KEY_vol_sound, 10));

    // ?
    loopmode = sp_cfg.getInt(Database.KEY_bgm_loopmode, BgMusic.MODE_LOOP);
    switch (loopmode) {
    case BgMusic.MODE_LOOP:
        ((Button) findViewById(R.id.config_loopmode)).setText(R.string.config_loop);
    case BgMusic.MODE_RANDOM:
        ((Button) findViewById(R.id.config_loopmode)).setText(R.string.config_random);
    case BgMusic.MODE_SINGLE:
        ((Button) findViewById(R.id.config_loopmode)).setText(R.string.config_single);
    }
    // ?

    if (sp_cfg.getBoolean(Database.KEY_use_custom_background, false)) {
        cfgflipper.setBackgroundDrawable(Drawable.createFromPath(customBgImage.getPath()));
    }

    OnClickListener clickListener = new OnClickListener() {

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.bgm_switch:
                boolean isBgOn = ((ToggleButton) v).isChecked();
                cfgEditor.putBoolean(Database.KEY_switch_bg, isBgOn);
                Message msg = new Message();
                msg.what = isBgOn ? 1 : 0;
                msg.arg1 = BgMusic.BGHandler.SWITCH_CHANGE;
                BgMusic.bgHandler.sendMessage(msg);
                break;
            case R.id.sound_switch:
                boolean isSoundOn = ((ToggleButton) v).isChecked();
                cfgEditor.putBoolean(Database.KEY_switch_sound, isSoundOn);
                MainMenu.se.setSwitch(isSoundOn);
                break;
            case R.id.config_vibration_switch:
                boolean isVibOn = ((ToggleButton) v).isChecked();
                cfgEditor.putBoolean(Database.KEY_switch_vibration, isVibOn);
                break;
            case R.id.config_playlist:
                if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
                    if (!isPlaylistChanged) {
                        loadPlaylistEditor();
                    }

                    cfgflipper.showNext();

                } else {
                    Toast.makeText(ConfigActivity.this, R.string.sdcard_unavailable, Toast.LENGTH_SHORT).show();
                }
                break;
            case R.id.config_ranking:
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("market://details?id=" + getPackageName()));
                startActivity(intent);
                break;

            case R.id.config_back:
                cfgEditor.commit();
                finish();
                break;

            case R.id.config_musiclist_back:
            case R.id.config_playlist_back:
                cfgflipper.showPrevious();
                break;

            case R.id.config_update:
                verCode = getVerCode(ConfigActivity.this);
                verName = getVerName(ConfigActivity.this);
                if (getServerVer()) {
                    if (newVerCode > verCode) {
                        doNewVersionUpdate(); // 
                    } else {
                        notNewVersionShow(); // ???
                    }
                }

                break;
            case R.id.config_loopmode:
                changeLoopMode();
                break;
            case R.id.config_quiz_submit:
                Intent intent1 = new Intent(ConfigActivity.this, CollectQuiz.class);
                startActivity(intent1);
                break;
            case R.id.config_change_bgimage:
                customBgImage();
                break;
            case R.id.config_restore_bgimage:
                restoreBgImage();
                break;
            case R.id.call_calendar_editor:
                Intent calendar = new Intent(ConfigActivity.this, CalendarEditor.class);
                startActivity(calendar);
                break;
            case R.id.who_are_we:
                if (aboutFHS == null) {
                    aboutFHS = (new AlertDialog.Builder(ConfigActivity.this)).setTitle(R.string.who_are_we)
                            .setMessage(R.string.about_fhs).setIcon(R.drawable.fhs_logo_48)
                            .setPositiveButton(android.R.string.ok, null).create();
                }
                aboutFHS.show();
                break;
            case R.id.licence:
                if (license == null) {
                    license = (new AlertDialog.Builder(ConfigActivity.this)).setTitle(R.string.license_title)
                            .setIcon(android.R.drawable.stat_sys_warning).setMessage(R.string.license)
                            .setPositiveButton(android.R.string.ok, null).create();
                }
                license.show();
                break;
            }
        }

    };

    bgm_toggle.setOnClickListener(clickListener);
    sound_toggle.setOnClickListener(clickListener);
    vibration_toggle.setOnClickListener(clickListener);
    config_playlist.setOnClickListener(clickListener);

    ((Button) findViewById(R.id.config_back)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_musiclist_back)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_playlist_back)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_update)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_quiz_submit)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_ranking)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_loopmode)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_change_bgimage)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.config_restore_bgimage)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.call_calendar_editor)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.who_are_we)).setOnClickListener(clickListener);
    ((Button) findViewById(R.id.licence)).setOnClickListener(clickListener);

    OnSeekBarChangeListener l_seekbar = new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
            switch (arg0.getId()) {
            case R.id.bgm_volume:
                cfgEditor.putInt(Database.KEY_vol_bg, arg1);
                Message msg = new Message();
                msg.what = arg1;
                msg.arg1 = BgMusic.BGHandler.VOL_CHANGE;
                BgMusic.bgHandler.sendMessage(msg);
                break;
            case R.id.sound_volume:
                cfgEditor.putInt(Database.KEY_vol_sound, arg1);
                MainMenu.se.setVolume(arg1);
                break;
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar arg0) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar arg0) {

        }

    };
    bgm_vol.setOnSeekBarChangeListener(l_seekbar);
    sound_vol.setOnSeekBarChangeListener(l_seekbar);
}

From source file:com.android.email.activity.zx.MessageView.java

private void onClickSender() {
    if (mMessage != null) {
        try {//from ww w  .j a va2 s . co m
            Address senderEmail = mMessage.getFrom()[0];
            Uri contactUri = Uri.fromParts("mailto", senderEmail.getAddress(), null);

            Intent contactIntent = new Intent(Contacts.Intents.SHOW_OR_CREATE_CONTACT);
            contactIntent.setData(contactUri);

            // Pass along full E-mail string for possible create dialog  
            contactIntent.putExtra(Contacts.Intents.EXTRA_CREATE_DESCRIPTION, senderEmail.toString());

            // Only provide personal name hint if we have one
            String senderPersonal = senderEmail.getPersonal();
            if (senderPersonal != null) {
                contactIntent.putExtra(Intents.Insert.NAME, senderPersonal);
            }

            startActivity(contactIntent);
        } catch (MessagingException me) {
            if (Config.LOGV) {
                Log.v(Email.LOG_TAG, "loadMessageForViewHeadersAvailable", me);
            }
        }
    }
}

From source file:net.bytten.comicviewer.ComicViewerActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    // Set up variables for a dialog and a dialog builder. Only need one of each.
    Dialog dialog = null;/*from  w  ww.j av  a 2  s  .co  m*/
    AlertDialog.Builder builder = null;

    // Determine the type of dialog based on the integer passed. These are defined in constants
    // at the top of the class.
    switch (id) {
    case DIALOG_SHOW_HOVER_TEXT:
        //Build and show the Hover Text dialog
        builder = new AlertDialog.Builder(ComicViewerActivity.this);
        builder.setMessage(comicInfo.getAlt());
        builder.setPositiveButton("Open Link...", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                openComicLink();
            }
        });
        builder.setNegativeButton("Close", null);
        dialog = builder.create();
        builder = null;
        break;
    case DIALOG_SHOW_ABOUT:
        //Build and show the About dialog
        builder = new AlertDialog.Builder(this);
        builder.setTitle(getStringAppName());
        builder.setIcon(android.R.drawable.ic_menu_info_details);
        builder.setNegativeButton(android.R.string.ok, null);
        builder.setNeutralButton("Donate", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                donate();
            }
        });
        builder.setPositiveButton("Developer Website", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                developerWebsite();
            }
        });
        View v = LayoutInflater.from(this).inflate(R.layout.about, null);
        TextView tv = (TextView) v.findViewById(R.id.aboutText);
        tv.setText(String.format(getStringAboutText(), getVersion()));
        builder.setView(v);
        dialog = builder.create();
        builder = null;
        v = null;
        tv = null;
        break;
    case DIALOG_SEARCH_BY_TITLE:
        //Build and show the Search By Title dialog
        builder = new AlertDialog.Builder(this);

        LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.search_dlg, (ViewGroup) findViewById(R.id.search_dlg));

        final EditText input = (EditText) layout.findViewById(R.id.search_dlg_edit_box);

        builder.setTitle("Search by Title");
        builder.setIcon(android.R.drawable.ic_menu_search);
        builder.setView(layout);
        builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                String query = input.getText().toString();
                Uri uri = comicDef.getArchiveUrl();
                Intent i = new Intent(ComicViewerActivity.this, getArchiveActivityClass());
                i.setAction(Intent.ACTION_VIEW);
                i.setData(uri);
                i.putExtra(getPackageName() + "LoadType", ArchiveActivity.LoadType.SEARCH_TITLE);
                i.putExtra(getPackageName() + "query", query);
                startActivityForResult(i, PICK_ARCHIVE_ITEM);
            }
        });
        builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        dialog = builder.create();
        builder = null;
        break;
    case DIALOG_FAILED:
        // Probably doesn't need its own builder, but because this is a special case
        // dialog I gave it one.
        AlertDialog.Builder adb = new AlertDialog.Builder(this);
        adb.setTitle("Error");
        adb.setIcon(android.R.drawable.ic_dialog_alert);

        adb.setNeutralButton(android.R.string.ok, null);

        //Set failedDialog to our dialog so we can dismiss
        //it manually
        failedDialog = adb.create();
        failedDialog.setMessage(errors);

        dialog = failedDialog;
        break;
    default:
        dialog = null;
    }

    return dialog;
}

From source file:com.corporatetaxi.TaxiOntheWay_Activity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_taxiontheway);
    taxiOntheWay_activity_instance = this;
    AppPreferences.setApprequestTaxiScreen(TaxiOntheWay_Activity.this, true);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextColor(Color.BLACK);
    setSupportActionBar(toolbar);//from  w w w . j  a  v a 2 s .com
    // getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    String title = getString(R.string.title_activity_taxidetail);
    getSupportActionBar().setTitle(title);

    fab_menu = (FloatingActionsMenu) findViewById(R.id.fab_menu);
    fab_msg = (FloatingActionButton) findViewById(R.id.fab_message);
    fab_call = (FloatingActionButton) findViewById(R.id.fab_call);
    fab_cancel = (FloatingActionButton) findViewById(R.id.fab_cancel);

    textheader = (TextView) findViewById(R.id.textheader);
    textname = (TextView) findViewById(R.id.name_text);
    textmobilenumber = (TextView) findViewById(R.id.mobile_text);
    textcompanyname = (TextView) findViewById(R.id.companyname);
    texttaxinumber = (TextView) findViewById(R.id.taxinumber);
    taxiname = (TextView) findViewById(R.id.taxinametext);
    mtextnamehead = (TextView) findViewById(R.id.namehead);
    mtextcompanyhead = (TextView) findViewById(R.id.companyhead);
    mtextmobilehead = (TextView) findViewById(R.id.mobilehead);
    mtexttexinumhead = (TextView) findViewById(R.id.taxiplatthead);
    taxinamehead = (TextView) findViewById(R.id.taxinamehead);
    mdriverimage = (ImageView) findViewById(R.id.driver_image);
    mdriverlicense = (TextView) findViewById(R.id.driverlicense);
    medriverinsurance = (TextView) findViewById(R.id.driverinsurance);

    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);

    getLocation();

    Typeface tf = Typeface.createFromAsset(this.getAssets(), "Montserrat-Regular.ttf");

    textheader.setTypeface(tf);
    mtextnamehead.setTypeface(tf);
    mtextcompanyhead.setTypeface(tf);
    mtextmobilehead.setTypeface(tf);
    mtexttexinumhead.setTypeface(tf);
    textname.setTypeface(tf);
    textmobilenumber.setTypeface(tf);
    textcompanyname.setTypeface(tf);
    texttaxinumber.setTypeface(tf);
    taxinamehead.setTypeface(tf);
    taxiname.setTypeface(tf);
    mdriverlicense.setTypeface(tf);
    medriverinsurance.setTypeface(tf);

    ////////current date time//////////////////
    currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date());
    Log.d("currentdatetime", currentDateTimeString);

    /////back arrow ////////////
    //        final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
    //        upArrow.setColorFilter(getResources().getColor(R.color.colorbutton), PorterDuff.Mode.SRC_ATOP);
    //        getSupportActionBar().setHomeAsUpIndicator(upArrow);

    /////////////notification data///////////////
    Intent intent = getIntent();
    String data = intent.getStringExtra("data");
    Log.d("data value", data + "");
    // caceldialog();
    JSONObject jsonObject = null;
    try {
        jsonObject = new JSONObject(data);
        AppPreferences.setAcceptdriverId(TaxiOntheWay_Activity.this, jsonObject.getString("driverId"));
        Log.d("driverid---", AppPreferences.getAcceptdriverId(TaxiOntheWay_Activity.this));
        drivermobile = jsonObject.getString("mobile");
        drivername = jsonObject.getString("username");
        drivercompanyname = jsonObject.getString("taxicompany");
        drivertaxiname = jsonObject.getString("vehicalname");
        drivertexinumber = jsonObject.getString("vehicle_number");
        // driverlatitude = jsonObject.getDouble("latitude");
        // driverlongitude = jsonObject.getDouble("longitude");
        driverimage = jsonObject.getString("driverImage");
        SourceAddress = jsonObject.getString("source_address");
        sourcelatitude = jsonObject.getDouble("source_latitude");
        sourcelongitude = jsonObject.getDouble("source_longitude");
        driverlicense = jsonObject.getString("driverlicense");
        driverinsurance = jsonObject.getString("driverinsurance");

        Log.d("driveriamge", driverimage);

        final LatLng loc = new LatLng(new Double(sourcelatitude), new Double(sourcelongitude));
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, 15));
        MarkerOptions marker = new MarkerOptions().position(loc).title(SourceAddress);
        marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_three));
        map.addMarker(marker);

        textname.setText(drivername);
        textmobilenumber.setText(drivermobile);
        textcompanyname.setText(drivercompanyname);
        texttaxinumber.setText(drivertexinumber);
        taxiname.setText(drivertaxiname);
        mdriverlicense.setText(driverlicense);
        medriverinsurance.setText(driverinsurance);

        if (mdriverlicense.length() == 0) {
            mdriverlicense.setVisibility(View.GONE);
        }
        if (medriverinsurance.length() == 0) {
            medriverinsurance.setVisibility(View.GONE);
        }

        Intent intent1 = new Intent(TaxiOntheWay_Activity.this, DriverService.class);
        intent1.putExtra("driverId", jsonObject.getString("driverId"));
        startService(intent1);

        //            loc2 = new LatLng(driverlatitude, driverlongitude);
        //            MarkerOptions marker2 = new MarkerOptions().position(loc2);
        //            marker2.icon(BitmapDescriptorFactory.fromResource(R.drawable.drivertaxi));
        //            map.addMarker(marker2);
        Timer timer;
        TimerTask task;
        int delay = 10000;
        int period = 10000;

        timer = new Timer();

        timer.scheduleAtFixedRate(task = new TimerTask() {
            public void run() {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        /*loc2 = new LatLng(new Double(AppPreferences.getCurrentlat(TaxiOntheWay_Activity.this)),
                            new Double(AppPreferences.getCurrentlong(TaxiOntheWay_Activity.this)));
                        MarkerOptions marker2 = new MarkerOptions().position(loc2);
                        map.clear();
                        marker2.icon(BitmapDescriptorFactory.fromResource(R.drawable.drivertaxi));
                        map.addMarker(marker2.title(drivername));*/
                        loc2 = new LatLng(new Double(AppPreferences.getCurrentlat(TaxiOntheWay_Activity.this)),
                                new Double(AppPreferences.getCurrentlong(TaxiOntheWay_Activity.this)));

                        if (marker1 == null) {
                            marker1 = map.addMarker(new MarkerOptions().position(loc2).title(drivername)
                                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.drivertaxi)));

                        }
                        animateMarker(marker1, loc2, false);

                    }
                });

            }
        }, delay, period);

    } catch (JSONException e) {
        e.printStackTrace();
    }
    /////////////notification dataend///////////////
    fab_cancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            initiatePopupWindowcanceltaxi();
        }
    });

    fab_msg.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            initiatePopupWindowsendmesage();
        }
    });
    fab_call.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent callIntent = new Intent(Intent.ACTION_CALL);
            callIntent.setData(Uri.parse("tel:" + drivermobile));
            startActivity(callIntent);
        }
    });

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
    if (driverimage.equalsIgnoreCase("")) {
        mdriverimage.setImageResource(R.drawable.ic_action_user);

    } else {
        Picasso.with(getApplicationContext()).load(driverimage).error(R.drawable.ic_action_user)
                .resize(200, 200).into(mdriverimage);
    }
}

From source file:com.remobile.camera.CameraLauncher.java

private void refreshGallery(Uri contentUri) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    mediaScanIntent.setData(contentUri);
    this.cordova.getActivity().sendBroadcast(mediaScanIntent);
}

From source file:com.example.okano.simpleroutesearch.MapsActivity.java

/**
 * //  w w  w.j  a  v  a 2s  .  c  om
//     * @param from
//     * @param to
 */
//    private void searchRoot(LatLng from, LatLng to){
private void searchRoot() {
    String fromLat = "35.681382";
    String fromLng = "139.7660842";
    String toLat = "35.684752";
    String toLng = "139.707937";

    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    //        intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
    //            intent.setClassName("com.example.okano.simpleroutesearch","com.example.okano.simpleroutesearch.MapsActivity");
    intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
    //        String fromLat = Double.toString(from.latitude) ;
    //        String fromLng = Double.toString(from.longitude) ;
    //        String toLat = Double.toString(from.latitude) ;
    //        String toLng = Double.toString(from.longitude) ;
    intent.setData(Uri.parse(
            "http://maps.google.com/maps?saddr=" + fromLat + "," + fromLng + "&daddr=" + toLat + "," + toLng));
    startActivity(intent);

}

From source file:com.xdyou.sanguo.GameSanGuo.java

public void enterGooglePlay() {
    String url = this.getClientUpdateUrl();
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Log.d("url", url);
    intent.setData(Uri.parse(url));
    startActivity(intent);/*www  .j  a  va2 s .  c  o m*/
}

From source file:com.xdyou.sanguo.GameSanGuo.java

public void execOpenUrl(String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Log.d("sanguo", "openUrl" + url);
    intent.setData(Uri.parse(url));
    startActivity(intent);// w w  w .  ja  va2s.c  o  m
}