My First iPhone Application – simple Book Library

Last week I attended a course on iPhone Application Development – Beginners

During the course we built a simple book library application.  This application has 4 different pages only:

  1. Home Page : listing only two items (Programming and My Books)
  2. List of Books : if you clicked on any item on home page will show the list of books of selected item
  3. Book Details : if you clicked on any book in the second page you will see the book details
  4. Add Book Form : if you where in “My Books” and you clicked on “+” button at the top right you will go to add book form

I am not on my Mac right now, otherwise I will place some screen shot of the application here. Any way, you can download the application from here:

http://www.4shared.com/file/F1pKSCWa/day42.html

downoad -> extract -> open -> build -> run 🙂

Advertisements

Using JSON in iPhone App Developlment

I am attending an iPhonh Application Development course these weeks. And in the next week we are going to deal with HTTP to gather XML data. As I know, and as instructor said, iPhone has built-in libraries to read and parse XML but there is nothing for JSON.

I decided to search and immediately I got this very useful post by Dan Grigsby on an interesting website:

Tutorial: JSON Over HTTP On The iPhon

http://mobileorchard.com/tutorial-json-over-http-on-the-iphone/

He explain “JSON and how to use” in very nice clear way, also there you will find a free library for JSON to use .. don’t miss it.

Run SQL script file from Dos command prompt

Note: The solution is at the bottom of the post, you can jump there directly if you don’t to read my silly story 😉

I have MS SQL Server 2008 R2 RTM – Express with Advanced Services. At work I got SQL script file from a client contains a table creating and record insertion scripts.

I tried to run SQL script file from SQL Management studio  but the file size was huge. So I got this error:

SQL2008RunScript

TITLE: Microsoft SQL Server Management Studio
——————————
Cannot execute script.
——————————
ADDITIONAL INFORMATION:
Insufficient memory to continue the execution of the program. (mscorlib)
——————————
BUTTONS:
OK
——————————

Then I decided to run the SQL script file from DOS command prompt as SQL server is supporting it.

I used this command:

osql -S <SQL Server IP/Name> -d <DB Name> -E -i <sql script file path>

where:

-S put your SQL server IP or Name
-d type your database name
-E the means trusted connect .. when you use this you don’t need to use -U & -P

in my case the command was:

osql -S dbserver -d SMSPortal -E -i c:\tmp\GroupContact.sql

Unfortunately, when I run the command I got another error that is:

[ODBC Driver Manager] Data source name not found and no default driver specified

after searching and digging I found that there are two files with name “osql.exe”. One in this folder:

C:\Program Files\Microsoft SQL Server\90\Tools\Binn\OSQL.EXE

and the second is in this folder:

C:\Program Files\Microsoft SQL Server\100\Tools\Binn\OSQL.EXE

But how to know which one is used when I run the command. While I am able to run the command from any place in command prompt that means the folder of one of two above files is added the PATH system variable. To check that, from DOS I run:

c:\>path

and I got this:

PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;

of course I got lengthy result but I truncated and removed unwanted stuff. Any way, as you can see both folders are added to the path. So I dont know which one is used when I run the command “osql …”. the best way is the navigate to the path of first folder and the command from there and navigate to the second folder and also run the file from there.

The Solution:

the file:

C:\Program Files\Microsoft SQL Server\90\Tools\Binn\OSQL.EXE

giving that same error:

[ODBC Driver Manager] Data source name not found and no default driver specified

While file:

C:\Program Files\Microsoft SQL Server\100\Tools\Binn\OSQL.EXE

Working fine and solved the problem.

So the command was like this:

C:\Program Files\Microsoft SQL Server\100\Tools\Binn>osql.exe -E -d SMSPortal -i c:\tmp\GroupContact.sql

with ruining this command I was able to run the script huge file successfully 🙂

Drow FlowChart, Wireframe, Database, System Design or Prototype

Updated 30-07-2013: (Last Option #4 is the best free)

While working in development  mobile, desktop or web application scope you will need a lot of tools to help you doing your work. I did and used a lot of tools, maybe I cant remember all of them but at least let me write about the tools I ‘m using while still I remember.

So for now I know to free application and using them in Windows. I am not sure if there is a Mac version of them or no.  Any way let me show you the tools:

1 – Dia

DiaDia has a wide usage more that just a flowchart. You can use it to explain any thing by drawing any chart various type of arrows.  This tool is totally free.  I can’t explain better than the publisher website .. so go there and check it your self 🙂

2 – Pencil

PencilThe main powerful advantage of this application is that it can be used as Firefox Add-on, that mean it can run wherever Firefox runs which mean cross-platform. This tool is totally free.  You will find all features and details you want in the publisher website .. go ahead >>

Update 29-06-2011 12:02 pm

3 – Mockup Builder

Mockup BuilderIs another tool to draw charts and prototyping. Like Pencil application (the second above)  this tool could work on browser .. but guess what?! it is not an extension for specific browser, it works directly because it is built as Silverlight application. So you only need to have Silverlight installed in your browser (mostly it will be already installed) it is like Flash. So no matter what browser you are using. I can say it is considered as cross platform web application.  Still there is also downloadable version to install it in your computer. The is free and still in beta .. but not sure about its future ..  anyway .. have a look into the publisher site >>

3 – draw.io

capture_020_30072013_175831It is a very nice free tool where you can draw several types of UML using different stencils, even for electronic circuits.

  • You can use the website without subscription.
  • Can download the file directly to your local PC as a bitmap or vector, in these formats (PNG, JPG, GIF, PDF, SVG, XML)
  • Generates HTML embed code
  • supports 30 languages
  • you can login using your google account to save your draw files in the cloud (Google Drive)
  • you can share your draw
  • supports plugins to add more stencils

I really like it .. it is amazing free tool.

That is for now .. =)

Good Android Resources I Use

Of course Google Android Developers
http://developer.android.com/sdk/installing.html

Android Application Development for Dummies
http://jacyar.googlecode.com/files/Android.Application.Development.for.For.Dummies.pdf 

Even can check Android Developers Google Group
http://groups.google.com/group/android-developers 

The application … (process …) has stopped unexpectedly. Please try again

This Bug Solved on Mon June 20, 2011

I am writing my first Andoid application. And facing an error .. I consider it too strange but also expecting to face a lot of strange errors and bugs.

I googled to find out what cause that error. And tried to learn how to debug Android application on Eclipse but no luck.

The application I am writing is having only an image and button. The button is to switch the mobile from normal mode to silent mode and the reverse and the image is an indicator the for which mode currently is active.

When I got the error I highlighted all the the code and started unhighlighting one by one, till I found the this line specifically cause the error:

int ringerMode = mAudioManager.getRingerMode();

when I run the application, on the Debug prespective view , in the error log tab I am getting :

Android Debug

here is a text copy of that error:

No command output when running: ‘am start -n ameen.android.silentModeToggle/ameen.android.silentModeToggle.Silent-
ModelToggleActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER’ on device emulator-5554

com.android.ddmlib.ShellCommandUnresponsiveException
	at com.android.ddmlib.AdbHelper.executeRemoteComm...
	at com.android.ddmlib.Device.executeShellCommand(...
	at com.android.ide.eclipse.adt.internal.launch.Ac...
	at com.android.ide.eclipse.adt.internal.launch.An...
	at com.android.ide.eclipse.adt.internal.launch.An...
	at com.android.ide.eclipse.adt.internal.launch.An...
	at com.android.ide.eclipse.adt.internal.launch.An...
eclipse.buildId=M20110210-1200
java.version=1.6.0_24
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86, WS=cocoa, NL=
en_US
Framework arguments:  -keyring /Users/ameen/.eclipse_key...
Command-line arguments:  -os macosx -ws cocoa -arch x86
-keyring /Users/ameen/.eclipse_keyring -showlocation

and here is all the code :

Android Bug

all other functions are highlighted.

I feel that something is missing in my development environment. Please I need help

I uploaded the zipped project folder into my DropBox folder if someone iterested to test it:

http://www.4shared.com/file/owbZCn0m/Silent_Model_Toggle.html

UPDATE – Mon June 20, 2011

The bug above is solved be a huge help from Mr. Greg Krimer (thank you) .. see details

He mentioned DDMS in hes message. DDMS (as I learned) is a way to debug your Android application in Eclipse. You can read learn it and read more about it from here.

DDMS

DDMS screenshot

The brief of bug reason as Mr Greg wrote:

As you can see, the cause of the problem is just a NullPointerException on line 22 of your activity owing to the fact that mAudioManager is used before it is unitialized. You initialize it on line 28.

So, I was having this line in my code:

int ringerMode = mAudioManager.getRingerMode();

and just by modified it to:

mAudioManager = (AudioManager)getSystemService(AUDIO_SERVICE);

int ringerMode = mAudioManager.getRingerMode();

it works fine 🙂 .. I am so happy

Skype is not connecting

Runtime Error!

Today in the company at certain time all the staff was not able to login to their Skype accounts; of course me too. Later also I started getting this error message (see also above image):

Runtime Error!
Program: C:\Program Files\Skype\Phone\Skype.exe
This application has requested the Runtime to terminate in an unusual way.
Please contact the application’s support team for mor information.

Mr. Bassam Asif sent me a solution for that problem, here we go:

Windows XP:

  1. show hidden files if they are not shown. how to show the hidden files and folders?
  2. go to folder: “C:\Documents and Settings\<your user name>\Application Data\Skype
  3. find the file shared.xml delete it or rename it to shared.xml.bak
  4. close Skype application totally, open it and try to login

Windows 7:

  1. show hidden files if they are not shown. how to show the hidden files and folders?
  2. go to folder: “C:\Users\<your user name>\AppData\Roaming\Skype
  3. find the file shared.xml delete it or rename it to shared.xml.bak
  4. close Skype application totally, open it and try to login

Ubuntue:

  1. open terminal
  2. type and exexute:
    #cd /home/<your user name>/.Skype
    #rm -rf shared.xml

I tried Windows XP steps but it does not work initially, after a while I became able to login to my Skype account. I don’t know if the mentioned steps solved the problem or it was common problem for all people and solved by Skype Company .. any way thanks to Asif =)