Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8114133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:03:37+00:00 2026-06-06T03:03:37+00:00

1) I need to launch an activity when the alarm triggers , I tried

  • 0

1) I need to launch an activity when the alarm triggers , I tried add the activity when in the onRecieve event of BroadCastReceiver but its failing.

public class AlarmReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent){
    Toast.makeText(context, "Recieved!!", Toast.LENGTH_LONG).show();

    Activity act = new Activity();
    act.startActivity(intent);
    }
}

Error:

06-22 13:42:00.733: W/dalvikvm(750): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-22 13:42:00.763: E/AndroidRuntime(750): FATAL EXCEPTION: main
06-22 13:42:00.763: E/AndroidRuntime(750): java.lang.RuntimeException: Unable to start receiver com.exercise.AndroidTime.AlarmReceiver: java.lang.NullPointerException
06-22 13:42:00.763: E/AndroidRuntime(750):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:1805)
06-22 13:42:00.763: E/AndroidRuntime(750):  at android.app.ActivityThread.access$2400(ActivityThread.java:117)
06-22 13:42:00.763: E/AndroidRuntime(750):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
06-22 13:42:00.763: E/AndroidRuntime(750):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-22 13:42:00.763: E/AndroidRuntime(750):  at android.os.Looper.loop(Looper.java:123)
06-22 13:42:00.763: E/AndroidRuntime(750):  at android.app.ActivityThread.main(ActivityThread.java:3683)
06-22 13:42:00.763: E/AndroidRuntime(750):  at java.lang.reflect.Method.invokeNative(Native Method)
06-22 13:42:00.763: E/AndroidRuntime(750):  at java.lang.reflect.Method.invoke(Method.java:507)
06-22 13:42:00.763: E/AndroidRuntime(750):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-22 13:42:00.763: E/AndroidRuntime(750):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-22 13:42:00.763: E/AndroidRuntime(750):  at dalvik.system.NativeStart.main(Native Method)
06-22 13:42:00.763: E/AndroidRuntime(750): Caused by: java.lang.NullPointerException
06-22 13:42:00.763: E/AndroidRuntime(750):  at android.app.Activity.startActivityForResult(Activity.java:2827)
06-22 13:42:00.763: E/AndroidRuntime(750):  at android.app.Activity.startActivity(Activity.java:2933)
06-22 13:42:00.763: E/AndroidRuntime(750):  at com.exercise.AndroidTime.AlarmReceiver.onReceive(AlarmReceiver.java:23)
06-22 13:42:00.763: E/AndroidRuntime(750):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:1794)
06-22 13:42:00.763: E/AndroidRuntime(750):  ... 10 more

2) How do I make an activity keep running even though the back button is pressed. Activity will close when certain criteria in the source code is met. Such as the alarm will not go off and he cant close the app also until user answers a question correctly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:03:39+00:00Added an answer on June 6, 2026 at 3:03 am

    Write below Code into your BroadcastReceiver class.

    Intent i = new Intent();
    i.setClassName("your package name", "your package name.your activity name");
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);
    

    instead of

    Activity act = new Activity();
    act.startActivity(intent);
    

    Define Receiver class into your androidmanifest.xml file.

    <receiver android:name="MyReceiver" >
        <intent-filter>
             <action android:name="de.vogella.android.mybroadcast" />
        </intent-filter>
    </receiver>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my activity, I create a Bitmap object and then I need to launch
I need to launch programs in my local system using VBScript. But I am
I need to launch/open one installed apk in my device from a BroadcastReceiver. Here
You may find this question before.But I need to restart the previous activity when
i need to add an help window to my android application. But actually i
I'm designed a TabHost and its having 3 TabSpec's so i need to add
I need to re-launch an activity to re-load a static library. If I want
I need to launch an app I've made just after login, before anything else
I need to launch call task in my wp7 app. once i launch this
I need to launch an external process, that at times, will lock up. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.