Skip to content

Instantly share code, notes, and snippets.

@varis
Created August 9, 2011 19:37
Show Gist options
  • Save varis/1134983 to your computer and use it in GitHub Desktop.
Save varis/1134983 to your computer and use it in GitHub Desktop.
Android / General
Toast.makeText(this, "Put your message here", Toast.LENGTH_SHORT).show();
// AndroidManifest.xml must have the following permission:
// <uses-permission android:name="android.permission.SEND_SMS"/>
SmsManager m = SmsManager.getDefault();
String destinationNumber ="0123456789";
String text = "Hello, MOTO!";
m.sendTextMessage(destinationNumber, null, text, null, null);
int notificationID = 10;
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// Create the notification
Notification notification = new Notification(R.drawable.yourIconId, "Put your notification text here", System.currentTimeMillis());
// Create the notification expanded message
// When the user clicks on it, it opens your activity
Intent intent = new Intent(this, YourActivityName.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(this, "Put your title here", "Put your text here", pendingIntent);
// Show notification
notificationManager.notify(notificationID, notification);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment