Posts

java - Can't retrieve Double from HashMap<Integer, Double> -

somehow can't retrieve double hashmap i've made using gson. map<integer, double> ratingmap = (map<integer, double>) new gsonbuilder() .create().fromjson(json, map.class); integer ifilmid = filmid; double rating = ratingmap.get(ifilmid); in code i've veried ratingmap contains {2=5.0}, when ratingmap.get(ifilmid) (where i've verified ifilmid in fact 2), variable rating null. missing here? i create hashmap in following way: if (json.equals("")) { // noting ever saved ratingmap = new hashmap<integer, integer>(); ratingmap.put(filmid, rating); } else { ratingmap = (map<integer, integer>) new gsonbuilder().create() .fromjson(json, map.class); ratingmap.put(integer.valueof(filmid), rating); } i let gson format integer double, , seems work fine can't retrieve it. the total code, including saving androids sharedpreferences public void saverating(int rati...

android - Using intents inside Service -

can use intent inside service? should put in "??????"? need call pedingintent alarm inside service.- example. public class calcularhorasservice extends service { public int horar; public int minr; private pendingintent pdintautomatico; @override public int onstartcommand( intent intent, int flags, int startid ) { // line key android.os.debug.waitfordebugger(); log.v( "servicio", "entro al servicio" ); getcalcularhorasalida(); setalarma(); // return return super.onstartcommand( intent, flags, startid ); } /** * set alarm */ private void setalarma() { intent intsincroauto = new intent( ????, alarmaactivarbroadauto.class ); pdintautomatico = pendingintent.getbroadcast( ????, 0, intsincroauto, 0); } } the constructor of intent require context first params, can put this because want create intent inside of service...

android - Why adb is under platform tools? -

i going through adb in android. why under platform tools? no matter, platform, should able install app on emulator or real device... should come under tools directory right generally speaking, platform-tools/ directory contains binaries specific development machine's os. example, running ubuntu linux, , have linux versions of adb , etc. else running windows have adb.exe , etc. the tools/ directory shell scripts , batch files. used both shipped development machines. see nowadays, split them development os (e.g., have android , not android.bat ).

javascript - Choosing page depending on users choices -

i'm trying create webpage user asked name(textbox) , gender(radio buttons) on front page. link new page dependent on whether chose if male or female, need display name entered in text box. so far have name part working using javascript on front page form action directed new page: // called on form's `onsubmit` function tosubmit() { // getting value of text input var mytext = document.getelementbyid("mytext").value; // storing value above localstorage localstorage.setitem("mytext", mytext); return true; } and on other page: // called on body's `onload` event function init() { // retrieving text input's value stored localstorage var mytext = localstorage.getitem("mytext"); // writing value in document document.getelementbyid("name").innerhtml = mytext; } the main problem here directs same page. can tell me how solve problem , add in option user choos...

c++ - MySQL server-side timeout -

i have connection code causes timeout when queries take long. connection options setup ( timeout integer): sql::connectoptionsmap com; com["hostname"] = url; // string com["username"] = user; // string com["password"] = pwd; // string com["opt_reconnect"] = true; com["opt_read_timeout"] = timeout; // 1 (second) com["opt_write_timeout"] = timeout; // 1 (second) after testing timeout setup above found throw occur mysql continues trying execute query. in other words, below try goes catch after configured timeout error code 2013 doesn't stop mysql trying execute query (2013 error code related lost connection): // other code try { stmt = con->createstatement(); stmt->execute("drop database if exists mysqlmanagertest_timeoutread"); stmt->execute("create database mysqlmanagertest_timeoutread"); stmt->execute("use mysqlmanagertest_timeoutread"); stmt-...

php - How come I cannot use bp_core_fetch_avatar() in the theme after I add filter in the plugin, wordpress buddypress? -

after add_filter code below in first plugin, cannot use bp_core_fetch_avatar() in second plugin or in theme, echo out same avatar every user, why? how can fix this? get_avatar can echo out different avatar base on user except cannot recognize $gender create in plugin tell if female or male, avatar assign base on gender . trying pass parameter $gender created in plugin, why think should figure out use bp_core_fetch_avatar(), way, get_avatar can pass parameter plugin?, know get_avatar( $id, $size,$default, $alt). anyway, want know why bp_core_fetch_avatar() echo out same avatar every user after add_filter, add 'item_id'=>"$id". thanks <?php add_filter('bp_core_fetch_avatar',array($this,'set_buddypress_avatar'), 10, 1); ?> <?php public function set_buddypress_avatar($html_data = ''){ $html_doc = new domdocument(); $html_doc->loadhtml($html_data); $image = $html_doc-...

r - Is it possible to use a metric (distance) unit in igraph cutoff argument? -

newbie igraph user here. i'm trying calculate betweenness values every segment (edge) in street network. ideally restrict calculations paths of less x metres considered. igraph::edge.betweenness.estimate function has cutoff argument restricts steps ( turns ) know if possible use metric distance instead. so far closest question have been able find http://lists.nongnu.org/archive/html/igraph-help/2012-11/msg00083.html on igraph help, , suggests might not possible. i have been using network aspatially, simple graph, have attribute of street segment length - lnklength . reading other stackoverflow posts possible use spatial networks igraph (with of spatial packages). if lnklength used weight network solve problem? if has ideas i'd grateful hear them. data <- data.frame( node1 = as.factor(c(aa, ab, ac, ad, ae, af, ag, ah, ai, aj)), node2 = as.factor(c(ba, bb, bc, aa, ab, ac, ba, bb, bc, aa)), lnklength =as.numeric(c(23.05, 42.81, 77.08, 39.63, 147.87, 56.46,...