• Asp.Net
  • MVC
  • C#
  • SQL Server
  • JavaScript
  • Learn from Life

Prakash Rathod

~ Passion is not a logic; it's an emotion.

Prakash Rathod

Category Archives: Android

Android SDK Manager does not open in windows 8

11 Wednesday Dec 2013

Posted by Prakash in Android, Uncategorized

≈ Comments Off on Android SDK Manager does not open in windows 8

I have installed windows 8 in my laptop and tried to open ‘Android SDK Manager’. It was not open. By googling I found the solution as below.

Go to android-sdk folder what you had set path under windows->preference menu for android.
Edit android.bat file.
Find java_exe=
And in front of add Java.exe path like “C:\Program Files (x86)\Java\jdk1.6.0\bin\java.exe”

HttpResponse to String android

18 Monday Mar 2013

Posted by Prakash in Android, Uncategorized

≈ Comments Off on HttpResponse to String android

HttpClient httpclient;
	HttpPost httppost;
	HttpResponse response;
httppost = new HttpPost("website-url-goes-here");
try {
				response = httpclient.execute(httppost);
				HttpEntity entity1 = response.getEntity();
				InputStream is = entity1.getContent();
				
				String w1url = convertStreamToString(is);
				
				
			} catch (ClientProtocolException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}

Add function into a class

private static String convertStreamToString(InputStream is) {

	    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
	    StringBuilder sb = new StringBuilder();

	    String line = null;
	    try {
	        while ((line = reader.readLine()) != null) {
	            sb.append((line + "\n"));
	        }
	    } catch (IOException e) {
	        e.printStackTrace();
	    } finally {
	        try {
	            is.close();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	    }
	    return sb.toString();
	}

Google cloud Messaging (GCM) for Android App and Asp.Net server app

23 Wednesday Jan 2013

Posted by Prakash in Android, Uncategorized

≈ Comments Off on Google cloud Messaging (GCM) for Android App and Asp.Net server app

At the Google IO 2012, the beta version of Android push notifications system called C2DM was replaced by Google Cloud Messaging (GCM). GCM has many new features over the existing system. Refer to this document for details of the differences and details about migrating your existing systems from C2DM to GCM.

To get started, download the Extras > Google Cloud Messaging for Android Library from the Android SDK.This library provides the jars to simplify the development on both the server side and client side.

From the Google API console page, create a new project and generate the API key. Refer this page for complete details.

Google provides the sample apps in the SDK by default, you may download a very basic version of them containing only the code discussed in this tutorial from here.
The same application is also available on play store here.

For .Net App download click here

Send free SMS API

11 Thursday Oct 2012

Posted by Prakash in Android, Asp.Net, c#.net, HTML5 CSS3, iPhone, JavaScript, Uncategorized

≈ Comments Off on Send free SMS API

http://ubaid.tk/api-usage/

Required Params : uid, pwd, phone, msg.

uid : your userid for the required sms provider
pwd : your password for the required sms provider
provider : way2sms(default), fullonsms, smsindia, whozzat, smsinside, site2sms. if you do not specify any provider, way2sms will be used by default.
phone : phone number whom you want to send sms. seperate multiple phone numbers with a comma (,)
msg : your sms message, unlimited chars. will be sent as multiple msgs if crosses the message length for any provider

Optional Parameters
codes : 1. Send this if you require a user friendly msg from the server. for example, if codes=1 is not provided the server will return the result as an integer.
1 – SMS sent
-1 – Server Error
-2 – Invalid Username
-3 – Invalid message text
-4 – Login Failed
-5 – IP Blocked

Google API

10 Thursday May 2012

Posted by Prakash in Android, Uncategorized

≈ Comments Off on Google API

Documentation for each api
Documetation For Each API

Search PLACE API code

CREATE API KEY

Alert Box in Android

30 Friday Sep 2011

Posted by Prakash in Android, Uncategorized

≈ Comments Off on Alert Box in Android

protected void alertbox(String title, String mymessage)
{
new AlertDialog.Builder(this)
.setMessage(mymessage)
.setTitle(title)
.setCancelable(true)
.setNeutralButton(android.R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton){}
})
.show();
}

For more details see below link…
http://huuah.com/dialog-boxes-in-android/

How to parse json string object in Android

30 Friday Sep 2011

Posted by Prakash in Android, Uncategorized

≈ Comments Off on How to parse json string object in Android

First of all you have understand what is jsonObject and jsonObjectArray.
ex. of jsonObject
{
“Validate”: “true”
}
if string start with “{” then it’s a only a object.
[
{
“Validate”: “true”
}
]
if string start with “[” then its array of object.

Here I describe both how to parse object or array of string as below.
Create a Class it has a one property.

public class Users {
public String Validate;
public void setUser(String Validate)
{
this.Validate = Validate;
}
public String getValidate()
{
return Validate;
}
}

—– bleow function parse json… create a new class which is parse json string
public class jsonParser {
JSONObject jsonObject;
JSONArray jsonArray;
Users objUser;

public jsonParser()
{
objUser = new Users();
}
public Users parseUser(String str)
{
try {
jsonObject = (JSONObject) new JSONObject(str);

objUser.companyId = jsonObject.getString(UserConstant.Company_Id);
objUser.FullName= jsonObject.getString(UserConstant.Full_Name);
objUser.LastLoginDate= jsonObject.getString(UserConstant.Last_Login_Date);
objUser.Password= jsonObject.getString(UserConstant.PASSWORD);
objUser.UserId = jsonObject.getString(UserConstant.User_Id);
objUser.Validate= jsonObject.getString(UserConstant.VALIDATE);
objUser.WrongPassCount= jsonObject.getInt(UserConstant.WRONGPASSCOUNT);
objUser.isActiveDirectory= jsonObject.getBoolean(UserConstant.IsActiveDirectory);

Log.d(“Json Result = ” , objUser.Validate);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
objUser=null;
}

return objUser;
}

public ArrayList parseUsers(String str)
{
ArrayList appUserList= new ArrayList();
Users user;
try {
jsonArray = (JSONArray) new JSONArray(str);
int arrayLength = jsonArray.length();

for(int i=0;i<arrayLength;i++)
{
user = new Users();
JSONObject arrayObject1 = jsonArray.getJSONObject(i);
user.setUser(arrayObject1.getString(UserConstant.Company_Id),
arrayObject1.getString(UserConstant.Full_Name),
arrayObject1.getString(UserConstant.Last_Login_Date),
arrayObject1.getString(UserConstant.PASSWORD),
arrayObject1.getString(UserConstant.User_Id),
arrayObject1.getString(UserConstant.VALIDATE),
arrayObject1.getInt(UserConstant.WRONGPASSCOUNT),
arrayObject1.getBoolean(UserConstant.IsActiveDirectory)
);
appUserList.add(user);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return appUserList;
}
}

Consume webservice in Android app

28 Wednesday Sep 2011

Posted by Prakash in Android, Uncategorized

≈ Comments Off on Consume webservice in Android app

First of all give internet permission to app for that below steps.
1. Open “AndroidManifest.xml” file.
2. Copy below code under

Now make one function which is consume web service.
public String doRequest(String requestURL)
{
InputStream is = null;
String jsonString = “”;
HttpClient httpClient = null;
HttpGet request = null;

try {

HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters,20*1000); // Connection timeout
HttpConnectionParams.setSoTimeout(httpParameters, 20*1000); // Socket timeout

// Create a new HttpClient and Post Header
httpClient = new DefaultHttpClient(httpParameters);

request = new HttpGet(requestURL);

HttpResponse httpResponse = httpClient.execute(request);

is = httpResponse.getEntity().getContent();

byte buff[] = new byte[1024];
int c = 0;
while ((c = is.read(buff)) != -1) {
jsonString += new String(buff, 0, c);
}
// Log.d(tag, “JSON-String =” + jsonString);
} catch (Exception e) {

e.printStackTrace();
return null;

} finally {
// Close opened streams.
// FIX
try {
if (is != null)
is.close();

if (httpClient != null)
httpClient = null;

if (request != null)
request = null;

} catch (IOException e) {
e.printStackTrace();
}
}
// Log.d(“HttpRequest”, “### Returning ” + jsonString);
return jsonString;
}

— CAll this function when you want to get result of web service —
String requestStr = “http://salesbook.iglobeapps.com/json/loginservice.svc/validateuser?email=demo1&password=demo111”;
String str = doRequest(requestStr);

Recent Posts

  • Create a custom autocomplete control in ASP.NET MVC
  • Nth Highest Salary
  • Generate x509 certificate in pem, cer and pfx and export public key
  • Send an image (stored as base64 string) inline in email
  • Put/Delete http verb not working server

Categories

  • Android
  • Asp.Net
  • BANKING
  • c#.net
  • Crystal Report
  • HTML5 CSS3
  • iPhone
  • JavaScript
  • Life – Spiritual – Reality
  • Lightswitch
  • Links
  • MAC
  • MVC
  • Netoworking
  • Silverlight
  • SQL Interview Questions
  • SQL Server
  • Uncategorized
  • Version Controls
  • Windows Store

Archives

  • August 2019
  • May 2019
  • April 2018
  • October 2017
  • August 2017
  • April 2017
  • March 2017
  • February 2017
  • December 2016
  • April 2016
  • January 2016
  • November 2015
  • January 2015
  • December 2014
  • October 2014
  • September 2014
  • June 2014
  • April 2014
  • March 2014
  • February 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • July 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • July 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009

© 2021 Prakash Rathod