Daily Archives

Articles indexed Sunday April 11 2010

Page 31/79 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • How do I pass data from a BroadcastReceiver through to an Activity being started?

    - by Tom Hume
    I've got an Android application which needs to be woken up sporadically throughout the day. To do this, I'm using the AlarmManager to set up a PendingIntent and have this trigger a BroadcastReceiver. This BroadcastReceiver then starts an Activity to bring the UI to the foreground. All of the above seems to work, in that the Activity launches itself correctly; but I'd like the BroadcastReceiver to notify the Activity that it was started by the alarm (as opposed to being started by the user). To do this I'm trying, from the onReceive() method of the BroadcastReceiver to set a variable in the extras bundle of the intent, thus: Intent i = new Intent(context, MyActivity.class); i.putExtra(wakeupKey, true); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); In the onResume() method of my Activity, I then look for the existence of this boolean variable: protected void onResume() { super.onResume(); String wakeupKey = "blah"; if (getIntent()!=null && getIntent().getExtras()!=null) Log.d("app", "onResume at " + System.currentTimeMillis() + ":" + getIntent().getExtras().getBoolean(wakeupKey)); else Log.d("app", "onResume at " + System.currentTimeMillis() + ": null"); } The getIntent().getExtras() call in onResume() always returns null - I don't seem to be able to pass any extras through at all in this bundle. If I use the same method to bind extras to the PendingIntent which triggers the BroadcastReceiver however, the extras come through just fine. Can anyone tell me what's different about passing a bundle from a BroadcastReceiver to an Activity, as opposed to passing the bundle from an Activity to a BroadcastReceiver? I fear I may be doing something very very obvious wrong here...

    Read the article

  • Type mismatch in expression in Delphi 7 on SQL append

    - by Demonick
    I have a code, that checks the current date when a form is loaded, performs a simple calculation, and appends a SQL in Delphi. It works on Windows 7 with Delphi 7, and on another computer with Xp, but doesn't on 3 other computers with Xp. When the form is loaded it shows a "Type mismatch in expression", and points to the line after the append. What could be the problem? procedure TfmJaunumi.FormCreate(Sender: TObject); var d1, d2: TDate; begin d1:= Date; d2:= Date-30; With qrJaunumi do begin Open; SQL.Append('WHERE Sanem_datums BETWEEN' + #39 + DateToStr(d1) + #39 + 'AND' + #39 + DateToStr(d2) + #39); Active := True; end; end;

    Read the article

  • How would I create a silverlight control for tagging content similar to StackOverflow?

    - by Dan Ryan
    I am new to Silverlight. How would I go about creating a control for users to tag content. I would like it to work like it does it StackOverflow i.e. Autocomplete and when you press space it inserts the tag in a box with a remove button. I want the control to be bindable to a collection of strings. If someone can just point me in the right direction to get me started I would be very grateful.

    Read the article

  • encodeURIComponent is really useful?

    - by Marco Demaio
    Something I still don't understand when perfoming an http-get request to the server is what the advantage is in using JS fucntion encodeURIcomponent to encode each component of the http-get. Doing some tests I saw the server (using PHP) gets the values of the http-get request properly also if I don't use encodeURIcomponent!!! Obviuosly I still need to encode at client level the special character & ? = / : otherwise an http-get value like this "peace&love=virtue" would be considered as new key value pair of the http-get request instead of a one single value. But why does encodeURIcompenent encodes also many other charcaters like 'è' for example wich is translated into %C3%A8 that must be decoded on a PHP server using the utf8_decode function. By using encodeURIcomponent all values of the http-get request are utf8 encoded, therefor when getting them in PHP I have to call each time the utf8_decode function on each $_GET value which is quite annoying. Why can't we just encode only the & ? = / : charcaters??? see also: http://stackoverflow.com/questions/2607946/js-encodeuricomponent-result-different-from-the-one-created-by-form It shows that encodeURIComponent does not even encode properly because a simple browser FORM GET encodes charactrs like '€', in different way. So I still wonder what does this encodeURIComponent is for?

    Read the article

  • C# select elements from IList

    - by user313884
    I have a list of objects: IList<O> O has several properties but only two of them are relevant: Date and Duration I want to "split" the list into several lists that contain only the objects that have matching Date and Duration Properties. Example: InitialList: 0- Date==1, Duration==7 1- Date==1, Duration==7 2- Date==2, Duration==7 3- Date==2, Duration==7 4- Date==2, Duration==14 5- Date==2, Duration==14 Desired result: IList<IList<O>: 0- 0- Date==1, Duration==7 1- Date==1, Duration==7 1- 0- Date==2, Duration==7 1- Date==2, Duration==7 2- 0- Date==2, Duration==14 1- Date==2, Duration==14 i know this can be done with some linq selects but am not sure how. thanks for the help.

    Read the article

  • Time complexity of a sorting algorithm

    - by Passonate Learner
    The two programs below get n integers from file and calculates the sum of ath to bth integers q(number of question) times. I think the upper program has worse time complexity than the lower, but I'm having problems calculating the time complexity of these two algorithms. [input sample] 5 3 5 4 3 2 1 2 3 3 4 2 4 [output sample] 7 5 9 Program 1: #include <stdio.h> FILE *in=fopen("input.txt","r"); FILE *out=fopen("output.txt","w"); int n,q,a,b,sum; int data[1000]; int main() int i,j; fscanf(in,"%d%d",&n,&q); for(i=1;i<=n;i++) fscanf(in,"%d",&data[i]); for i=0;i<q;i++) { fscanf(in,"%d%d",&a,&b); sum=0; for(j=a;j<=b;j++) sum+=data[j]; fprintf(out,"%d\n",sum); } return 0; } Program 2: #include <stdio.h> FILE *in=fopen("input.txt","r"); FILE *out=fopen("output.txt","w"); int n,q,a,b; int data[1000]; int sum[1000]; int main() { int i,j; fscanf(in,"%d%d",&n,&q); for(i=1;i<=n;i++) fscanf(in,"%d",&data[i]); for(i=1;i<=n;i++) sum[i]=sum[i-1]+data[i]; for(i=0;i<q;i++) { fscanf(in,"%d%d",&a,&b); fprintf(out,"%d\n",sum[b]-sum[a-1]); } return 0; } The programs below gets n integers from 1 to m and sorts them. Again, I cannot calculate the time complexity. [input sample] 5 5 2 1 3 4 5 [output sample] 1 2 3 4 5 Program: #include <stdio.h> FILE *in=fopen("input.txt","r") FILE *out=fopen("output.txt","w") int n,m; int data[1000]; int count[1000]; int main() { int i,j; fscanf(in,"%d%d",&n,&m); for(i=0;i<n;i++) { fscanf(in,"%d",&data[i]); count[data[i]]++ } for(i=1;i<=m;i++) { for(j=0;j<count[i];j++) fprintf(out,"%d ",i); } return 0; } It's ironic(or not) that I cannot calculate the time complexity of my own algorithms, but I have passions to learn, so please programming gurus, help me!

    Read the article

  • How do I flatten an associative array into an array with only values in PHP?

    - by aalaap
    I have an array that has keys and values. For eg: Array ( [name] => aalaap [age] => 29 [location] => mumbai ) I want to convert the keys from this into values, but I want the values to apear right after the keys. For eg: Array ( [0] => name [1] => aalaap [2] => age [3] => 29 [4] => location [5] => mumbai ) I can easily write an iteration function that will do this... for eg: array_flatten($arr) { foreach ($arr as $arrkey => $arrval) { $arr_new[] = $arrkey; $arr_new[] = $arrval; } return $arr_new; } ...but I'm trying to find out if there's any way this can be accomplished using array_combine, array_keys, array_values and/or array_merge, preferably in one, so i don't need to use a custom function. Is there?

    Read the article

  • CSS Experts required - problems with Z-Index stack in my page design

    - by Jack W-H
    Howdy y'all! Basically I'm having some problems with Z-Index. Although I'm not amazing at CSS I would reckon I was reasonably good, but really can't work this out. You'll see at the URL... http://howcode.com/code/ ... that my problem is that links in the returned 'Popular' results aren't clickable or anything. I've concluded this is due to their Z-Index being messed up. I had to fiddle and tweak with Z-Index to get the tabs - Popular, Top Rated, Featured etc. - to show above the codebg div. When I adjusted the Z-Index so that the results were definitely on top, they acted as normal - text could be selected, the ratings images hovered, etc. etc. However the downside to this was that my Popular, Top Rated, Featured tabs were all placed BENEATH the background image for the returned results. If anyone can post a workaround or alteration to my CSS that would be much appreciated. Please don't forget this is a test site and design and any other URLs are likely not to work, I haven't uploaded any database configs yet or whatever! Attached are a couple of screenshots to clarify what I mean: This is what I WANT to happen (not that in actual fact in this screenshots link aren't clickable, just to demo my point though): This is what DOES happen when I adjust the Z-Index properties (I don't want this!): Thanks y'all!

    Read the article

  • next element is (current+1) or 0 (ruby)

    - by Radek
    I have an interval let's say (0..3) where next element is +1 unless the last. Then the next is 0. I solved it by the code below. Just wondering if there is anything else outhere :-) def next(max,current) if current+1 == max return 0 else return current+1 end end

    Read the article

  • Help with SQL query (Calculate a ratio between two entitiess)

    - by Mestika
    Hi, I’m going to calculate a ratio between two entities but are having some trouble with the query. The principal is the same to, say a forum, where you say: A user gets points for every new thread. Then, calculate the ratio of points for the number of threads. Example: User A has 300 points. User A has started 6 thread. The point ratio is: 50:6 My schemas look as following: student(studentid, name, class, major) course(courseid, coursename, department) courseoffering(courseid, semester, year, instructor) faculty(name, office, salary) gradereport(studentid, courseid, semester, year, grade) The relations is a following: Faculity(name) = courseoffering(instructor) Student(studentid) = gradereport (studentid) Courseoffering(courseid) = course(courseid) Gradereport(courseid) = courseoffering(courseid) I have this query to select the faculty names there is teaching one or more students: SELECT COUNT(faculty.name) FROM faculty, courseoffering, gradereport, student WHERE faculty.name = courseoffering.instructor AND courseoffering.courseid = gradereport.courseid AND gradereport.studentid = student.studentid My problem is to find the ratio between the faculty members salary in regarding to the number of students they are teaching. Say, a teacher get 10.000 in salary and teaches 5 students, then his ratio should be 1:5. I hope that someone has an answer to my problem and understand what I'm having trouble with. Thanks Mestika

    Read the article

  • Delete element from Set

    - by Blitzkr1eg
    Hi. I have 2 classes Tema(Homework) and Disciplina (course), where a Course has a Set of homeworks. In Hibernate i have mapped this to a one-to-many associations like this: <class name="model.Disciplina" table="devgar_scoala.discipline" > <id name="id" > <generator class="increment"/> </id> <set name="listaTeme" table="devgar_scoala.teme"> <key column="Discipline_id" not-null="true" ></key> <one-to-many class="model.Tema" ></one-to-many> </set> </class> <class name="model.Tema" table="devgar_scoala.teme" > <id name="id"> <generator class="increment" /> </id> <property name="titlu" type="string" /> <property name="cerinta" type="binary"> <column name="cerinta" sql-type="blob" /> </property> </class> The problem is that it will add (insert rows in the table 'Teme') but it won't delete any rows and i get no exceptions thrown. Im using the merge() method.

    Read the article

  • Best Database Change Control Methodologies

    - by SnapJag
    As a database architect, developer, and consultant, there are many questions that can be answered. One, though I was asked recently and still can't answer good, is... "What is one of, or some of, the best methods or techniques to keep database changes documented, organized, and yet able to roll out effectively either in a single-developer or multi-developer environment." This may involve stored procedures and other object scripts, but especially schemas - from documentation, to the new physical update scripts, to rollout, and then full-circle. There are applications to make this happen, but require schema hooks and overhead. I would rather like to know about techniques used without a lot of extra third-party involvement.

    Read the article

  • How to add authors page, authors profile and pics on Wordpress?

    - by April
    Hello, I am looking for a plugin that would add the folloiwng on our blog site built on Wordpess slef hosted: Authors' name to appear on every blog (below title where currentlly date and tags appear) Authors page being added to our blog site On authors page display authors' profile including bio, website, social network profile buttons and published posts. So it would be more like how it is set-up at Mashable: http://mashable.com/author/pete-cashmore/. Is there a plugin or plugins I could use to achieve these? Thank for help.

    Read the article

  • Asynchronous vs Synchronous vs Threading in an iPhone App

    - by Coocoo4Cocoa
    I'm in the design stage for an app which will utilize a REST web service and sort of have a dilemma in as far as using asynchronous vs synchronous vs threading. Here's the scenario. Say you have three options to drill down into, each one having its own REST-based resource. I can either lazily load each one with a synchronous request, but that'll block the UI and prevent the user from hitting a back navigation button while data is retrieved. This case applies almost anywhere except for when your application requires a login screen. I can't see any reason to use synchronous HTTP requests vs asynchronous because of that reason alone. The only time it makes sense is to have a worker thread make your synchronous request, and notify the main thread when the request is done. This will prevent the block. The question then is bench marking your code and seeing which has more overhead, a threaded synchronous request or an asynchronous request. The problem with asynchronous requests is you need to either setup a smart notification or delegate system as you can have multiple requests for multiple resources happening at any given time. The other problem with them is if I have a class, say a singleton which is handling all of my data, I can't use asynchronous requests in a getter method. Meaning the following won't go: - (NSArray *)users { if(users == nil) users = do_async_request // NO GOOD return users; } whereas the following: - (NSArray *)users { if(users == nil) users == do_sync_request // OK. return users; } You also might have priority. What I mean by priority is if you look at Apple's Mail application on the iPhone, you'll notice they first suck down your entire POP/IMAP tree before making a second request to retrieve the first 2 lines (the default) of your message. I suppose my question to you experts is this. When are you using asynchronous, synchronous, threads -- and when are you using either async/sync in a thread? What kind of delegation system do you have setup to know what to do when a async request completes? Are you prioritizing your async requests? There's a gamut of solutions to this all too common problem. It's simple to hack something out. The problem is, I don't want to hack and I want to have something that's simple and easy to maintain.

    Read the article

  • [SOLVED]Port C's fread(&struct,....) to Python

    - by user287669
    Hey, I'm really struggling with this one. I'am trying to port a small piece of someone else's code to Python and this is what I have: typedef struct { uint8_t Y[LUMA_HEIGHT][LUMA_WIDTH]; uint8_t Cb[CHROMA_HEIGHT][CHROMA_WIDTH]; uint8_t Cr[CHROMA_HEIGHT][CHROMA_WIDTH]; } __attribute__((__packed__)) frame_t; frame_t frame; while (! feof(stdin)) { fread(&frame, 1, sizeof(frame), stdin); // DO SOME STUFF } Later I need to access the data like so: frame.Y[x][y] So I made a Class 'frame' in Python and inserted the corresponding variables(frame.Y, frame.Cb, frame.Cr). I have tried to sequentially map the data from Y[0][0] to Cr[MAX][MAX], even printed out the C struct in action but didn't manage to wrap my head around the method used to put the data in there. I've been struggling overnight with this and have to get back to the army tonight, so any immediate help is very welcome and appreciated. Thanks

    Read the article

  • Wordpress > Transfer google verification file to root directory on plugin activation/install

    - by Scott B
    I've got a wordpress plugin which presets several settings in a wordpress site and creates some default pages which are the same for all my sites. I would like to include an html file in my plugin zip package that is placed into the site's root directory "as is" (same file name, etc) The file is my google verification file, which is the same for all my sites, so I'd like to save a few steps and automate the process of installing it, along with my default setup steps that my plugin handles. Any help, much appreciated.

    Read the article

  • How to use Apache HWPF to extract text and images out of a DOC file

    - by Hamed
    Hi...! I downloaded the Apache HWPF. I want to use it to read a doc file and write its text into a plain text file. I don't know the HWPF so well. My very simple program is here: I have 3 problems now: 1-Some of packages have errors ( they can't find apache hdf). How I can fix them? 2-How I can use the methods of HWDF to find and extract the images out? 3-Some piece of my program is incomplete and incorrect.So please help me to complete it. I have to complete this program in 2 days. once again I repeat Please Please help me to complete this. Thanks you Guys a lot for your help!!! This is My Elementary code : import org.apache.poi.poifs.filesystem.*; import org.apache.poi.hwpf.*; import org.apache.poi.hwpf.extractor.*; import org.apache.poi.hwpf.model.PicturesTable; import org.apache.poi.hwpf.usermodel.Picture; public class test { public void m1 (){ String filesname = "Hello.doc"; POIFSFileSystem fs = null; fs = new POIFSFileSystem(new FileInputStream(filesname ); HWPFDocument doc = new HWPFDocument(fs); WordExtractor we = new WordExtractor(doc); String str = we.getText() ; String[] paragraphs = we.getParagraphText(); Picture pic = new Picture(. . .) ; pic.writeImageContent( . . . ) ; PicturesTable picTable = new PicturesTable( . . . ) ; if ( picTable.hasPicture( . . . ) ){ picTable.extractPicture(..., ...); picTable.getAllPictures() ; } }

    Read the article

  • Animate the enabling of a UIBarButtonItem?

    - by Michael Brewer
    Is there a way to animate enabling or disabling a button? I've tried the following with no success. I'm guessing at this point that the enabled property cannot be animated like opacity can – but I hope I'm wrong. [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0f]; theButton.enabled = YES; [UIView setAnimationDelegate:self]; [UIView commitAnimations]; I can't believe there isn't a setEnabled:(BOOL)enabled animated:(BOOL)animated method.

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >