Monday, October 25, 2010

How to maintance the phone ?

25 Oct 2010
How to change Google Account Password ?
Go to Menu -> Settings -> Applications -> Manage Applications
Click on GMail in the list and, if needed, "Force Stop" then "Clear data"
Click on Google Apps in the list and, if needed, "Force Stop" it, but DO NOT clear data
Click on "Clear Data" on GMail Storage
Back to home and open any Google Application
Re-enter your Google account information.

Friday, October 1, 2010

How to access Services ?

01 Oct 2010
How to cancel Notification ?
int NOTIFICATION_ID= 1234;
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

manager.cancel(NOTIFICATION_ID);

30 Sep 2010
How to show Notication ?

CharSequence title = "Title";
CharSequence text = "Text";
Context c = getApplicationContext();

Intent intent = new Intent(c, Main.class);
PendingIntent intent2 = PendingIntent.getActivity(c, 0, intent, 0);

Notification n = new Notification(R.drawable.icon, text, System.currentTimeMillis());
n.defaults = Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE;
n.setLatestEventInfo(c, title, text, intent2);

NotificationManager m = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
m.notify(1, n);

18 Aug 2010
How to open Photos ?
startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), 0);

public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
Uri selectedImage = data.getData();
try {
InputStream fileInputStream = getApplicationContext().getContentResolver().openInputStream(selectedImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}

16 Aug 2010
How to dismiss keyboard ?
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

How to access clipboard ?
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipboard.setText("testing");

How to vibrate ?
Vibrator vv = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);