Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package test.test;
- import android.app.Activity;
- import android.app.Dialog;
- import android.app.Notification;
- import android.app.NotificationManager;
- import android.app.PendingIntent;
- import android.content.Context;
- import android.content.Intent;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- public class TesttActivity extends Activity implements OnClickListener {
- private Dialog dialog;
- private static final int HELLO_ID = 1;
- Button b1;
- Bundle hej;
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- hej = getIntent().getExtras();
- initilize();
- }
- private void initilize() {
- // TODO Auto-generated method stub
- b1 =(Button)findViewById(R.id.Button1);
- b1.setOnClickListener(this);
- }
- public void onClick(View v) {
- // TODO Auto-generated method stub
- switch(v.getId()){
- case R.id.Button1:
- createNotification(1325, "test", "testNote");
- Object test = hej.get("Note");
- String hk = test.toString();
- Log.i("test", ""+test);
- break;
- }
- }
- private void createNotification(int id,String MessageTitle,String MessageBody) {
- // TODO Auto-generated method stub
- String ns = Context.NOTIFICATION_SERVICE;
- NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
- int icon = R.drawable.ic_launcher;
- CharSequence tickerText = "Hello";
- long when = System.currentTimeMillis();
- Notification notification = new Notification(icon, tickerText, when);
- Context context = getApplicationContext();
- CharSequence contentTitle = MessageTitle;
- CharSequence contentText = MessageBody;
- Intent notificationIntent = new Intent(this, TesttActivity.class);
- notificationIntent.putExtra("category", "category1");
- notificationIntent.putExtra("Note", "note1");
- PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
- notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
- mNotificationManager.notify(id, notification);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement