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 7586083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:20:14+00:00 2026-05-30T19:20:14+00:00

Well I wanted to make an AppWidget, I define the layouts,info for app widget,

  • 0

Well I wanted to make an AppWidget, I define the layouts,info for app widget, a broadcast receiver and a service to handle AppWidget.

            AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this
            .getApplicationContext());
    int[] allWidgetIds = intent
            .getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);

    ComponentName thisWidget = new ComponentName(getApplicationContext(),
            SmsSchedulerWidget.class);

    RemoteViews remoteViews = new RemoteViews(this.getApplicationContext()
            .getPackageName(), R.layout.schdulesms_appwidget_layout);

    DatabaseManager dbManager = new DatabaseManager(context.getApplicationContext());
    dbManager.open();
    String contactNumber = dbManager.fetchContactNumber();
    String date = dbManager.fetchDate();
    String message = dbManager.fetchMessage();
    String status = dbManager.fetchStatus();

    remoteViews.setTextViewText(R.id.to_appwidget_saved_data, contactNumber);
    remoteViews.setTextViewText(R.id.date_appwidget_saved_data, date);
    remoteViews.setTextViewText(R.id.status_appwidget_saved, message);
    remoteViews.setTextViewText(R.id.message_appwidgset_saved_data, status);

    appWidgetManager.updateAppWidget(thisWidget, remoteViews);

This is my code………….

But in other activities i can easily retrieve database values without any null pointer exception. Please if anybody could point out whats wrong with my code than i will be higly grateful…………….

The log cat errors are:

03-02 17:26:32.174: E/AndroidRuntime(32265): FATAL EXCEPTION: main
03-02 17:26:32.174: E/AndroidRuntime(32265): java.lang.RuntimeException: Unable to start service com.android.braindigit.schedulesms.appWidgetService@4053da30 with Intent { cmp=com.android.braindigit.schedulesms/.appWidgetService (has extras) }: java.lang.NullPointerException
03-02 17:26:32.174: E/AndroidRuntime(32265): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2052)
03-02 17:26:32.174: E/AndroidRuntime(32265): at android.app.ActivityThread.access$2800(ActivityThread.java:117)
03-02 17:26:32.174: E/AndroidRuntime(32265): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:994)
03-02 17:26:32.174: E/AndroidRuntime(32265): at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 17:26:32.174: E/AndroidRuntime(32265): at android.os.Looper.loop(Looper.java:130)
03-02 17:26:32.174: E/AndroidRuntime(32265): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-02 17:26:32.174: E/AndroidRuntime(32265): at java.lang.reflect.Method.invokeNative(Native Method)
03-02 17:26:32.174: E/AndroidRuntime(32265): at java.lang.reflect.Method.invoke(Method.java:507)
03-02 17:26:32.174: E/AndroidRuntime(32265): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-02 17:26:32.174: E/AndroidRuntime(32265): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-02 17:26:32.174: E/AndroidRuntime(32265): at dalvik.system.NativeStart.main(Native Method)
03-02 17:26:32.174: E/AndroidRuntime(32265): Caused by: java.lang.NullPointerException
03-02 17:26:32.174: E/AndroidRuntime(32265): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:118)
03-02 17:26:32.174: E/AndroidRuntime(32265): at com.android.braindigit.schedulesms.DatabaseManager.open(DatabaseManager.java:36)
03-02 17:26:32.174: E/AndroidRuntime(32265): at com.android.braindigit.schedulesms.appWidgetService.onStart(appWidgetService.java:41)
03-02 17:26:32.174: E/AndroidRuntime(32265): at android.app.Service.onStartCommand(Service.java:428)
03-02 17:26:32.174: E/AndroidRuntime(32265): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2039)
03-02 17:26:32.174: E/AndroidRuntime(32265): … 10 more

  • 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-05-30T19:20:15+00:00Added an answer on May 30, 2026 at 7:20 pm

    Well I dont know how genuine it is to answer my own question but i thought it would help other people if they have the same problem as me…..So, after banging my head for hours, finally i realised that i was passing a null context.So, i did the following things and it worked….

    from the broadcase receiver I passed the following intents to my service:

        Intent intent = new Intent(context.getApplicationContext(),appWidgetService.class);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS,allWidgetIds);
        intent.putExtra("contactNumber", contactNumber);
        intent.putExtra("date", date);
        intent.putExtra("message",message);
        intent.putExtra("status", status);
        //update the widgets via the service
    

    and in service i did the following things:

        String contactNumber = intent.getStringExtra("contactNumber");
        String date = intent.getStringExtra("date");
        String message =intent.getStringExtra("message");
        String status = intent.getStringExtra("status");
    
    
        for (int widgetId : allWidgetIds) {
            RemoteViews remoteViews = new RemoteViews(this
                    .getApplicationContext().getPackageName(),
                    R.layout.schdulesms_appwidget_layout);
    
    
    
            remoteViews.setTextViewText(R.id.to_appwidget_saved_data,
                    contactNumber);
            remoteViews.setTextViewText(R.id.date_appwidget_saved_data, date);
            remoteViews.setTextViewText(R.id.status_appwidget_saved, message);
            remoteViews.setTextViewText(R.id.message_appwidgset_saved_data,
                    status);
    
            appWidgetManager.updateAppWidget(thisWidget, remoteViews);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wanted find more information regarding this. I intend to make an app right
Just wanted to get the groups thoughts on how to handle configuration details of
So I was feeling bored and decided I wanted to make a hangman game.
I have been bitten by something unexpected recently. I wanted to make something like
So I wanted to make my UIWebview respon to touch events. I have read
I wanted to scramble a String, to make it unreadable and so came up
I'm rewriting our NAnt build scripts to make them cleaner and simpler, as well
Lots of words below, sorry - but I wanted to explain this situation well:
I wanted to make my own WebApp for testing so I will know what
Just wanted to make sure: When I write: require('/path/to/file/file.php'); Is the file required with

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.