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);
No comments:
Post a Comment