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

  • Home
  • SEARCH
  • 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 7957847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:19:31+00:00 2026-06-04T04:19:31+00:00

I have an Android application that works with sms messages. When new sms message

  • 0

I have an Android application that works with sms messages. When new sms message arrives Android, will call code from my class that is “NEW_SMS” broadcast receiver. As you know, “onReceive” method in my “sms_recieved_class” gets some context (from the system). Using intents, my sms broadcast receiver calls another class that does something with sms database (context originally got from system via “onReceive” is used to invoke code from other class by sending another broadcast).

That other class works with sms database and it’s also a broadcast receiver. It reacts on broadcasts sent by my class mentioned above. If “messing” with database goes wrong, app should show custom error dialog. Now, THERE’s the problem!

Custom error dialog code:

public static void setUpError(Context act,String ERRMSG, StackTraceElement[] stack) {

AlertDialog.Builder builder = new AlertDialog.Builder(act);

    final StackTraceElement[] finStack = stack;
    final String errMsg=ERRMSG;
    final Context ctxFin = act;

    builder.setMessage(poruka)...setting up alert buttons...

    AlertDialog alert = builder.create();
    alert.show();

}

Error goes off at “alert.show()” line. I’m confused cause when i try to show this dialog while my app is visible (and pass “someAct.this” as Context) everything is fine. When i try to show alert using Context taken from “broadcastReceiver.onReceive” (called by the system) i got error. What i’m doing wrong?

P.S. after searching for answer on STOVF, every time the solution was “don’t use getApplicationContext()”. Since both of my classes that are called when phone gets new message AREN’T of type “Activity”, what should i do?

  • 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-04T04:19:31+00:00Added an answer on June 4, 2026 at 4:19 am

    First of all, Dialog needs activity that is on screen (so without any opened activity, you cannot show Dialog). What you can do is create activity that will look like Dialog. Check this question from SO.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with my Android application. I need an application that will send
I am new to android please guide me.. I have flash light application that
I have an android application that works like restriction of some Apps categories like
I have created android application that uses Google Maps, ans it works fine here
I have an Android application that connects to Facebook to request authorization of an
I have an Android application that uses the Android database to create tables and
I have an android application that displays a toast every hour and then every
I have an android application that requres a login based on users in a
I have an android application that has 3 activites. For the 1st and 2nd
I have a simple Android application that uses a JAR I have built. When

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.