Posts

android - Move an object from one Activity to a Service -

android - Move an object from one Activity to a Service - i need move object activity service. effort @ activity side. waveform waveform = new waveform(); intent intent = new intent(this, stimulationservice.class); bundle bundle = new bundle(); bundle.putparcelable("test", (parcelable) waveform); intent.putextras(bundle); startservice(intent); i have placed code in onstart() function in service. bundle bundle = this.getintent().getextras(); if(bundle!=null) mwaveform = bundle.getparcelable(waveform); i'm getting errors function "getintent" , "waveform" within getparcelable(). help or guidance appreciated. services don't have getintent method. instead intent passed in argument onstart method. should utilize parameter instead. the getparcelable method takes string , in case of test code, should "test" . android android-intent android-activity

youtube api - Would it be possible to fetch videos on a certain tag published between certain dates -

youtube api - Would it be possible to fetch videos on a certain tag published between certain dates - we utilize google-api-java-client lookup videos , know if possible fetch videos on tag (say sports) published between dates (starting yesterday till now). how do this? i able using google-api-client 1.6.0-beta (downloaded via maven). modified illustration code little. api had changed since illustration code written. added query parameters youtube api reference guide , extended video class include couple more fields. if @ raw json returned query see add together several others fields including thumbnails, duration, aspect ratio, comment count etc. hope helps. import com.google.api.client.googleapis.googleheaders; import com.google.api.client.googleapis.json.jsoncparser; import com.google.api.client.http.*; import com.google.api.client.http.javanet.nethttptransport; import com.google.api.client.json.jsonfactory; import com.google.api.client.json.jackson.jacksonfac...

Android TimePicker SetTitle UIThread Issues -

Android TimePicker SetTitle UIThread Issues - i understand calledfromwrongthreadexception exception means, cannot comprehend how code have written isn't executing on uithread in situation. in main activity create handler. private final handler handler = new apphandler(this); in oncreatedialog method of activity, using constructor suggested android examples of timepicker dialogues. since getting calledfromwrongthreadexception in way didn't understand , wasn't reproducible on devices or emulator, tried pass reference of activity in create dialogue constructor. so code create dialog looks this. @override protected dialog oncreatedialog(int id) { final calendar c = calendar.getinstance(); switch (id) { case time_dialog_id: homecoming new timepickerdialog(this, this, gethandler(), mtimesetlistener, c.get(calendar.hour_of_day), 0, false); the first instance of "this" gets used context dialog, se...

c# - How can I find the first regex that matches my input in a list of regexes? -

c# - How can I find the first regex that matches my input in a list of regexes? - is there way write following? string input; var match = regex.match(input, @"type1"); if (!match.success) { match = regex.match(input, @"type2"); } if (!match.success) { match = regex.match(input, @"type3"); } basically, want run string thru gammut of expressions , see 1 sticks. var patterns = new[] { "type1", "type2", "type3" }; match match; foreach (string pattern in patterns) { match = regex.match(input, pattern); if (match.success) break; } or var patterns = new[] { "type1", "type2", "type3" }; var match = patterns .select(p => regex.match(input, p)) .firstordefault(m => m.success); // in original example, match lastly match if // unsuccessful. expect accident, if want // behavior, can instead: var match = patterns .select(p => regex.match(inp...

netty - How would you extend a Channel? -

netty - How would you extend a Channel? - i need little help netty. wondering how extend channel interface , add together own methods , create netty utilize (or cast it)? matt. i guess improve solution "wrap" channel class store class in channellocal or in channelhandlercontext. jsut retrieve implementation , utilize it. allow switch between nio , oio without need worry implementation. i'm doing similar in niosmtp: https://github.com/normanmaurer/niosmtp/blob/master/src/main/java/me/normanmaurer/niosmtp/transport/netty/nettysmtpclientsession.java this helps decouble code. to provide own channel need hack socket implementation. think should avoid whenever possible. netty

python - Regular Expression for Email address -

python - Regular Expression for Email address - here weird regular look emails . we can have various kind of email addresses string1@somemail.com string1@somemail.co.in string1.string2@somemail.com string1.string2@somemail.co.in the next regular look can find of mails above email2="santa.banta@gmail.co.in" email1="arindam31@yahoo.co.in'" email="bogusemail123@sillymail.com" email3="santa.banta.manta@gmail.co.in" email4="santa.banta.manta@gmail.co.in.xv.fg.gh" email5="abc.dcf@ghj.org" email6="santa.banta.manta@gmail.co.in.org" re.search('\w+[.|\w]\w+@\w+[.]\w+[.|\w+]\w+',email) x=re.search('\w+[.|\w]\w+@\w+[.]\w+[.|\w+]\w+',email2) x.group() santa.banta@gmail.co.in' x=re.search('\w+[.|\w]\w+@\w+[.]\w+[.|\w+]\w+',email1) x.group() arindam31@yahoo.co.in' x=re.search('\w+[.|\w]\w+@\w+[.]\w+[.|\w+]\w+',email) x.group() 'bogusemail123@sillymail.com...

javascript - How do I test if an element with a certain ID exists on a page in jQuery? -

javascript - How do I test if an element with a certain ID exists on a page in jQuery? - in jquery, have written piece of code appears on every page of website. var d = $('#someelement').offset().top; however, not every page on website has element id of "someelement". unfortunately, on these pages lack such element, no jquery code works. to solve problem, want test if element on page indeed has id of "someelement" , run code snippet above if there is. how perform test? test solve problem? give thanks you. $('#someelement').length homecoming 1 if element exists, 0 otherwise. javascript jquery