Tone

your force close is due to the fact that you haven't set the flags
necessary for calling an activity from a receiver..
here is how you should call a
public void onReceive(Context context, Intent intent)
        {
                Intent startalarm=new Intent(context,YOUR_CLASS_TO_CALL);
startalarm.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|
Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(startalarm);
      }

Setting these flags will solve your problem

Regards
Gino

On Jan 14, 7:35 am, Justin Anderson <[email protected]> wrote:
> The force close is quite commonly caused by a null pointer ecxeption...
>
> The logcat info should be able to tell you where (and what) the problem is.
>
> On Jan 13, 2010 10:14 AM, "Tone" <[email protected]> wrote:
>
> In order to learn how to use the AlarmManager I created an activity
> that consists of a single button. When the button is pressed the
> activity creates an Intent of itself and loads it into the
> AlarmManager 3 seconds in the future before finishing.
>
> So activity opens, user pushes button, activity closes, 3 seconds
> later activity opens, repeat.
>
> Problem is instead of opening an activity 3 seconds later I get an
> error:
> "The application [myappname] has stopped unexpectedly. Please try
> again."
>
> Here's the code for the button:
> thanksButton.setOnClickListener(new View.OnClickListener() {
>                public void onClick(View view) {
>                setResult(RESULT_OK);
>
>                Intent intent = new Intent(myappname.this,
> myappnameBroadcastReceiver.class);
>                PendingIntent appIntent = PendingIntent.getBroadcast
> (myappname.this, 0, intent, 0);
>                Calendar calendar = Calendar.getInstance();
>                calendar.setTimeInMillis(System.currentTimeMillis());
>                calendar.add(Calendar.SECOND, 3);
>                AlarmManager am = (AlarmManager)getSystemService
> (ALARM_SERVICE);
>                am.set(AlarmManager.RTC, calendar.getTimeInMillis(),
> appIntent);
>
>                finish();
>                }
>
>        });
>
> --------------------------------------------
> Here's the broadcast receiver:
> package com.myappname;
>
> import android.content.BroadcastReceiver;
> import android.content.Context;
> import android.content.Intent;
>
> public class myappnameBroadcastReceiver extends BroadcastReceiver {
>       �...@override
>        public void onReceive(Context context, Intent intent) {
>                        context.startActivity(new Intent(context,
> myappname.class));
>        }
>
> }
>
> ---------------------------------------------
> and here's the lines from the manifest.xml
>
>                <receiver
>                        android:name=".myappnameBroadcastReceiver"
>                        android:process=":remote">
>                </receiver>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow 
> athttp://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> [email protected]<android-beginners%[email protected]>
> For more options, visit this group 
> athttp://groups.google.com/group/android-beginners?hl=en
-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

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