this is notification test class and test1 another activity
while running notification I get status msg when I click to start
another activity
activity is not started plz check it your system and tell me where I
am going wrong


import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.util.Timer;
import java.util.TimerTask;

public class test extends Activity {
        private static final int NOTIFY_ME_ID=1337;
        private Timer timer=new Timer();
        private int count=0;
        
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
                
                Button btn=(Button)findViewById(R.id.notify);
                
                btn.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View view) {
                                TimerTask task=new TimerTask() {
                                        public void run() {
                                                notifyMe();
                                        }
                                };
                
                                timer.schedule(task, 5000);
                        }
                });
                
                btn=(Button)findViewById(R.id.cancel);
                
                btn.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View view) {
                                NotificationManager mgr=
                                        
(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
                                        
                                mgr.cancel(NOTIFY_ME_ID);
                        }
                });
        }
        
        private void notifyMe() {
                final NotificationManager mgr=
                        
(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
                Notification note=new Notification(R.drawable.icon,     "Status 
message!",
                                                                                
                                                                                
System.currentTimeMillis());
                PendingIntent i=PendingIntent.getActivity(this, 0,
                                                                                
                                new Intent(this,test1.class),
                                                                                
                                                                                
                        0);
                
                note.setLatestEventInfo(this, "Notification Title",
                                                                                
                                "This is the notification message", i);
                note.number=++count;
                
                mgr.notify(NOTIFY_ME_ID, note);
        }
}



this is test1 class
import android.app.Activity;
import android.os.Bundle;
import android.widget.*;


public class test1  extends Activity
{
        public void onCreate(Bundle d)
        {
                super.onCreate(d);
                TextView dd=new TextView(this);
                dd.setText("hello world");
                setContentView(dd);
        }

}


<application android:icon="@drawable/icon" android:label="welcome">
        <activity android:name=".test"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
       <activity android:name=".test1"
                  android:label="welcome"/>

    </application>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to