Posts

c# - Not able to convert JSON to Java class (call WebApi from Android app) -

im working on school project , im new in android programming have programming experiance in c# , .net. this code: public class proizvodiapi { public class proizvodivm implements serializable { public integer proizvodid; public string naziv; public string sifra; public bigdecimal cijena; public byte[] slikathumb; public string jedinicamjere; public string vrstaproizvoda; } public class proizvodilista implements serializable { public list<proizvodivm> proizvodi; } public static void getallproizvode(final myrunnable<proizvodilista> onsuccess) { requestqueue queue = volley.newrequestqueue(myapp.getcontext()); string url = "proizvodi/getproizvodivm"; // request string response provided url. stringrequest stringrequest = new stringrequest(request.method.get, config.urlapi + url, new response.listener...

Android: Unable to start service with null: java.lang.NullPointerException -

before begin, want make clear have read previous answers similar topics (mainly this one ) , answer given in comments didn't work me (adding intent != null before intent.getaction() didn't work). i'm trying make foreground service mayan horoscope. purpose of service read horoscope symbols , prediction sqlite database , whenever recieves text message following: "maya dd/mm/yyyy" (the dob), service obtain info , send text message automatically. have gotten work background service without error, want give notification user can see if service running or not. i have followed other tutorials ( tutorial 1 , tutorial 2 ) make foreground service , works fine without error. my problem whenever start service, stop service , clear ram (killing app) nullpointer exception time on service's line 57 (no matter code have it's line 57). on phone gives me message "unfortunately horoscopomaya has stopped working." twice! manifest.xml <?xml version=...

mysql - Insert the mysqli_insert_id inside separate table using PHP -

i'd submit new registered user auto_increment id inside table1 , @ same time insert mysqli_insert_id or last_insert_id ever want call inside table2. can echo id out, need inside table2. how can accomplish that? please help! here code reference: <?php if(isset($_post['submit'])) { require 'connect.php'; $sql = "insert table1 (username, password) values ('".$_post["username"]."','".$_post["password"]."')"; if (mysqli_query($con, $sql)) { $last_id = mysqli_insert_id($con); echo "new record created successfully. last inserted id is: " . $last_id; } else { echo "error: " . $sql . "<br>" . mysqli_error($con); } mysqli_close($con); } ?> use variable last inserted id (successful) query insert other table. this rough sketch don't know db schema second table , quite unclear, need (fill in) rest. if (mysqli_query($con, $sql...

javascript newbie: what's the right way to apply the same behavior to multiple elements? -

i'm taking first adventure javascript, , totally without bearings. i'd show thumbnail opens modal larger view of picture (and front end fanciness i'll need, i'm trying keep simple). i've copied this code w3schools, uses getelementbyid. works great first image on page clicking subsequent images doesn't pop up. reading around on stack overflow sounds that's because i'm matching on id, each element on page will/should have different id (which makes sense). i saw post here person made ids unique appending element's id. that, (a) wanted check if that's kosher , (b) id no longer match, there different attribute tack on match html styles? must common problem- what's right way apply same behavior multiple elements on page? example can give them thanks! update : based on everyone's feedback below i've modified code use getelementbyclassname instead of getelementbyid- see gist here: https://gist.github.com/dianekaplan/1602a7c0a1...

wpf - Is MVVM pattern a symbiote of MVC + PAC patterns? -

i've surfed wikipedia , have found such article: http://en.wikipedia.org/wiki/mvc4wpf a part link upper: mvc4wpf open-source, extensible, automated code pattern developed @ information control corporation windows presentation foundation (wpf) development based on model-view-controller (mvc) , presentation-abstraction-control (pac) patterns... i know, wpf/silverlight use mvvm pattern: model-view-viewmodel. so mvc4wpf first version of mvvm? i don't know history of wpf/silverlight development well, mvvm has remind me sort of mvc. and if it's true, mvvm = mvc + pac ? whenever see questions this, think dr. wpf's design pattern . it doesn't matter want call separate concerns. hear lot of wpf people talk mvvm, boils down trying keep code separate. in mvvm, have: model data classes. knows nothing anything. view gotta show data. knows models, not how them. "knows" viewmodel through bindings. depending on how wire them together, ma...

audio - C++ OpenAL will not play WAV file -

so have written method meant accept file path .wav file, go through creation of buffers , sources, , play sound. apparently, no sound play when run program. none of error checks trigger, there's nothing wrong file. have scoured google past few hours , have come empty handed, wanted ask here. here code: file* fp = null; fp = fopen("audiofile.wav", "rb"); char type[4]; dword size, chunksize; short formattype, channels; dword samplerate, avgbytespersec; short bytespersample, bitspersample; dword datasize; fread(type, sizeof(char), 4, fp); if (type[0] != 'r' || type[1] != 'i' || type[2] != 'f' || type[3] != 'f') fatalerror("openal error: no riff"); fread(&size, sizeof(dword), 1, fp); fread(type, sizeof(char), 4, fp); if (type[0] != 'w' || type[1] != 'a' || type[2] != 'v' || type[3] != 'e') fatalerror("openal error: not wave file"); fread(type, sizeof(char), 4, ...

java - Creating a new file each time and reading from it -

so i'm trying store new book user enters external text file includes title of book, author, , isbn. i have achieved making file. however, each time rerun program create new book, says file exists. how can make program add existing file? or should make make new file each time? thanks in advance. public class testmylibrary { //declare global var //create file in documents static file myfile=new file("/users/adambunch/documents/library.rtf"); //create library object static library lib=new library ("400 main st."); //scanner read file static scanner input=new scanner(system.in); static int choice; //user inputs choice keyboard //main method public static void main(string[] args) throws filenotfoundexception { //3 ways create books , add them library //first way book book1=new book("the lord of rings", "sally smith", 12345); lib.addbook(b...