UI of Balckberry

package com.screv;

import net.rim.device.api.ui.UiApplication;


public class SampleApp extends UiApplication {

public SampleApp() {

pushScreen(new SampleAppScreen());
}
public static void main(String[] args) {

SampleApp sampleApp = new SampleApp();
sampleApp.enterEventDispatcher();
}

}

GPS Location in Android

public class GPSLocationListener implements LocationListener{

@Override
public void onLocationChanged(Location location) {
if(location != null)
{
point = new GeoPoint((int)(location.getLongitude() * 1E6), (int) (location.getLatitude() * 1E6));
//Toast.makeText(getBaseContext(), "point " +point.getLatitudeE6(), Toast.LENGTH_LONG).show();

address = ConvertPointToLocation(point);
//Toast.makeText(getBaseContext(), "Address: " +address, Toast.LENGTH_LONG).show();
}
}

public String ConvertPointToLocation(GeoPoint point){

String address= "";

Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault());
//Toast.makeText(getBaseContext(), "after getting geocoder", Toast.LENGTH_LONG).show();

try{
//Toast.makeText(getBaseContext(), "before getting address", Toast.LENGTH_LONG).show();

List
addresses = geoCoder.getFromLocation(point.getLongitudeE6() / 1E6, point.getLatitudeE6() / 1E6, 1);
//Toast.makeText(getBaseContext(), "addresses size " +address.length(), Toast.LENGTH_LONG).show();

if(addresses.size() > 0){
for(int index = 0; index < addresses.get(0).getMaxAddressLineIndex(); index++){
address += addresses.get(0).getAddressLine(index) + " ";
}
}
}catch(Exception e){
//Toast.makeText(getBaseContext(), "exception " +e.getMessage(), Toast.LENGTH_LONG).show();
}
return address;
}

@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub

}

@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub

}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub

}
}

Notiifcation in Android

Log.i("DispAudioAlert","Before ");
nManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
notification = new Notification(android.R.drawable.stat_sys_data_bluetooth, "Lost Bluetooth Device", System.currentTimeMillis());



notification.defaults = Notification.DEFAULT_ALL;
Context context = getApplicationContext();

Email Proxy for Android

public class EmailProxy extends Activity{

static Data da = ConfigurationActivity.d;
private static String mail;

public static String getMailAddress() throws SQLException {
da.open();
Cursor c = null;
c = da.fetchConfiguration();
mail = c.getString(1);
Log.i("EmailProxy","Mail: "+mail);
c.close();
da.close();
return mail;
}


public static String getEntities(String Url, HashMap params){
String response=null;
try{

//String q = Url.trim()+generateQueryString(params);
response = sendRequest(Url.trim()+generateQueryString(params));

}/*catch(ServerExecutionException e){
throw e;
}*/catch(Exception e){
return response;
}
return response;
}

private static String generateQueryString(HashMap params)
{
if(params==null)
return "";

Set keys = params.keySet();

StringBuilder queryString = new StringBuilder();
queryString.append("?");

for(String key:keys)
{
String value=params.get(key);
if(value!=null)
value=value.replaceAll(" ", "%20");

queryString.append(key).append("=").append(value).append("&");
}
String requestString=queryString.toString().substring(0, queryString.toString().length()-1);

return requestString;
}

private static String sendRequest(String weburl)throws Exception{
Log.i("Url",weburl);

String responseText="";
HttpClient client = new DefaultHttpClient();
HttpResponse response = null;

Log.i("Request Url is",weburl);

//HttpGet getMethod = new HttpGet(weburl);

HttpPost getMethod = new HttpPost(weburl);

Log.i("GetMethod",getMethod.toString());


client.getParams().setParameter("http.connection.timeout", new Integer(10000));
response = client.execute(getMethod);

Log.i("respose",response.toString());

try{
InputStream in = response.getEntity().getContent();
responseText = getStringFromInputStream(in);
}catch(Exception e){
Log.i("Exception",e.getMessage());

throw new Exception("Some Error Has occured.");
}
return responseText;
}

private static String getStringFromInputStream(InputStream in) {

BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuffer buffer = new StringBuffer();
String line="";

try {
while((line=reader.readLine())!=null){
buffer.append(line).append(System.getProperty("line.separator"));
}
} catch (IOException e) {

e.printStackTrace();
}
return buffer.toString();
}

create option menu in Android in XML file








create option menu in Android in XML file

Create option Menu in Android in any Activity Class

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.option_menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.satellite:
map.setSatellite(true);
return true;
case R.id.street:
map.setStreetView(true);
return true;
}
return false;
}