A better file manager
I've been playing around on my S2 quite a lot, but today I wanted to see if I could access my PC's shared folder over my wireless network. It turns out the default android file browser cannot do it, so I turned to my old friend, Google.
A very quick search led me to an app called ES File Explorer, which turned out to be an amazing file manager replacement for the Android platform.
In less than almost no time, I was listening to some mp3 files that were shared on my PC. I even tried watching a movie file, and the built in movie player handled it with no problems at all.
Anyway, ES File Manager has got to be very high on the list of apps that you absolutely MUST get on your android phone.
Till next time!
Baca Selengkapnya ....
Blogger Android app
Yup, I just installed the free blogger app on my phone. In fact, I'm making this very post with it! Also took a quick photo of Einstein, our one dog.
Will mention all the worthwhile apps I install as I go along...
I must admit, I'm having lots of fun with my phone so far, which is probably the main reason the battery isn't lasting ;-)
Till next time!
Baca Selengkapnya ....
My Samsung Galaxy S2 specs
- Released April 2011 (we only got it in July in South Africa - whoop!)
- 2G - GSM 850 / 900 / 1800 / 1900
- 3G - HSDPA 850 / 900 / 1900 / 2100
- Size - 125.3 x 66.1 x 8.5mm (8.5mm is really thin)
- Weight - 116g (really light as well!)
- Display - Super AMOLED Plus capacitive touchscreen, with 16 million colours (same as pc's), resolution is 480x800 pixels, and the screen size is 4.3 inches.
- 3.5mm jack, so you can plug any headphones in the device
- On board memory, either 16 or 32GB (I got the South African version, which will always be the smaller one, the 16GB)
- It has a micro-SD card slot, and according to GSM-Arena it comes with an 8GIG micro-SD card, but not in sunny South Africa, I got a measly 1GB card. I think I must give Vodacom a call about this...
- 8MP camera with an LED flash, and a 2MP front facing camera
- A very VERY fast dual-core 1.2GHz CPU, and a Mali-400MP GPU
- Mine was loaded with Android Gingerbread, version 2.3.3
- 3G speeds - on HSDPA, up to 21Mbps, and HSUPA up to 5.76Mbps
- Bluetooth V3.0
- WLAN
- GPS
- Also, I believe this phone is capable of phoning and sms'ing as well, will test and let everyone know! :)
Baca Selengkapnya ....
A short intro
Baca Selengkapnya ....
How to care your Laptop Battery
Battery is an important part of the Laptop. Because the mobility of the laptop exactly depends on the battery life of the laptop. If the battery has good charging capacity and if it can supply power for a long period the battery may be consider as good battery.
There are many types of batteries available in the market. Following are the most popular and common types of battery.
Lithium-ion (Li-ion) Batteries
Lithium-ion battery is a new technology of batteries. Most of modern laptops uses Li-ion batteries. It is lighter weight and higher performance. Li-ion batteries are not susceptible to “Memory Effect”. We will later talk about the “Memory Effect”. Initial condition will effect good life time of Li-ion battery.
Nickel-metal Hydride (NiMH) Batteries
Although it is susceptible to memory effect, it is less susceptible to memory effect than NiCd Batteries. It should be conditioned once per 2 or 3 week. Condition is fully discharge the battery and fully charge it again.
Nickel Cadmium (NiCd) Batteries
NiCd is the oldest battery technology. NiCd battery has good performance. But, it is tremendously susceptible for Memory Effect. Let’s say when we charge the battery we charge it to 90% of the battery capacity. If we doing this over and over again battery tend to keep a memory as 90% is the fully charged state of the battery. Then battery won’t charge in to its full capacity. If we always discharge the battery to 30% of the battery capacity, battery keeps the memory as 30% is the fully discharged state. This is the “Memory Effect” incident and this will reduce the use of battery recourse.
Now, Lest discuss how to care our laptop battery.
- When you use the battery first time, you should fully charge and discharge (condition cycle) for first three cycles.
- Keep the battery contact terminal clean always. This helps maintain a good connection between the battery and your laptop.
- If the battery will not be in use for a month or longer, it is recommended that it be removed from the device and stored in a cool, dry, clean place.
- Use the AC (alternative current) adapter always you can. There is no any overcharging happen. When the battery completely charged, in every laptop there is mechanism to disconnect the battery from the AC current. Then the laptop will work from the AC power.
- Condition the battery for every 2 or 3 months. Don’t charge the battery so that the memory effect happens. This bullet point is not applicable to Li-ion batteries. Li-ion batteries don’t want to condition frequently and those are not affected to Memory effect.
- Use power management plans available in your system. Turn down the LCD brightness. Set screen saver blank to small time limit as much as.
- Use suitable RAM size to your laptop. If you have a RAM which is large enough to store your all frequent data, it will save large amount of power. Using hard drive to fetch data always is power exhaustive process.
- Close all unused software and processes.
- Don’t open short-circuit the battery terminals. It will damage the battery permanently.
- Don’t open the battery cover as the cell contents expose and don’t modify the battery casing.
Baca Selengkapnya ....
Android Services
we need to distinguish between A Service and a Thread or an AsyncTask: Threads or Async task perform their tasks in a background thread thus they do not block the main thread, while a service performs it's work in the main thread. so if a service is performing an intensive task such as calling a web service, it may block the main thread until it finishes. So for intensive tasks a service should run it's work in a background thread.
A service runs in the same process of the application and keeps running until stopped by itself, stopped by the user or killed by the system if it needs memory.
Creating a service:
to create a service we create a class that extends android.app.Service and it would be like this:public class DemoService extends Service {next we need to define our service in our AndroidManifest.xml file:
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
}
<service android:name="DemoService"></service>The service life cycle has the following events
- onCreate(): called when the service is created.
- onStart(): Called when the service starts by a call to startService(Intent intent).
- onDestroy(): Called as the service is terminates.
Calling a service:
A service can be called from an activity in two ways:- By calling startService(Intent intent).
- By binding to the service through an Binder object.
calling startService(Intent intent):
to start a service from an activity using this method, we create an intent and start the service like this:Intent intent=new Intent(this,DemoService.class);the startService(intent) method causes the onStart() method of the service to be called, so the service can execute it's work like this:
startService(intent);
public class DemoService extends Service {the service will keep running until it stops itself via stop stopSelf() after finishing work:
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
doSomething();
}
public void doSomething(){
// do some work
}
}
@Overrideor it can be stopped from the activity via stopService(Intent intent).
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
doSomething();
stopSelf();
}
Binding to a service through an Binder object:
As the service runs in the same process of the application the service has only one instance (singleton) instance running. you may want to keep reference to this instance to perform periodical tasks or to call the service methods themselves.to make the service bind-able we extends Binder class and return an instance of it in the service's onBind(Intent intent) method:
public class DemoService extends Service {then we bind the service from our activity by first creating a ServiceConnection object to handle the service connection/disconnection then binding to the service by an intent like this:
private final IBinder binder = new LocalBinder();
@Override
public IBinder onBind(Intent arg0) {
return binder;
}
public class LocalBinder extends Binder {
DemoService getService() {
return DemoService.this;
}
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
doSomething();
stopSelf();
}
public void doSomething(){
// do something
}
}
public class MainActivity extends Activity {notice that we unbind the service in the activity's onDestroy() method to disconnect from the service and stop it from executing any further
DemoService mService;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
ServiceConnection serviceConn=new ServiceConnection() {
/**
* service unbound, release from memory
**/
@Override
public void onServiceDisconnected(ComponentName name) {
mService=null;
}
/**
* service is bound, start it's work
**/
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService=((LocalBinder)service).getService();
mService.doSomething();
}
};
@Override
protected void onResume() {
super.onResume();
// bind to the service by an intent
Intent intent=new Intent(this,DemoService.class);
// AUTO CREATE: creates the service and gives it an importance so that it won't be killed
// unless any process bound to it (our activity in this case) is killed to
bindService(intent, serviceConn, Context.BIND_AUTO_CREATE);
}
@Override
protected void onDestroy() {
super.onDestroy();
/ unbind the service whena ctivity is destroyed
unbindService(serviceConn);
}
}
and that's was all about Android services, stay tuned for another Android tutorial.
Baca Selengkapnya ....
Parsing JSON respone:
"persons"this response is a JSON Array with the name "persons", this array consists of "person" JSON Objects.
[
{
"person"{
"firstName": "John",
"lastName": "Smith",
"age": 25
}
}
{
"person"{
"firstName": "Catherine",
"lastName": "Jones",
"age": 35
}
}
]
to parse such a reponse:
public ArrayList<Person> getMessage(String response){
JSONObject jsonResponse;
ArrayList<Person> arrPersons=new ArrayList<Person>;
try {
// obtain the reponse
jsonResponse = new JSONObject(response);
// get the array
JSONArray persons=jsonResponse.optJSONArray("persons");
// iterate over the array and retrieve single person instances
for(int i=0;i<persons.length();i++){
// get person object
JSONObject person=persons.getJSONObject(i);
// get first name
String firstname=person.optString("firstname");
// get last name
String lastname=person.optString("lastname");
// get the age
int age=person.optInt("age");
// construct the object and add it to the arraylist
Person p=new Person();
p.firstName=firstname;
p.lastName=lastname;
p.age=age;
arrPersons.add(p);
}
} catch (JSONException e) {
e.printStackTrace();
}
return arrPersons;
}
notice that we used the methods optJSONArray,optString,optInt instead of using getString,getInt because the opt methods return empty strings or zero integers if no elements are found. while the get methods throw an exception if the element is not found.
Baca Selengkapnya ....