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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:23:45+00:00 2026-06-05T18:23:45+00:00

I’m having the error Unable to instantiate activity ComponentInfo in my app. I had

  • 0

I’m having the error “Unable to instantiate activity ComponentInfo” in my app. I had already declared the Activity in AndroidManifest.xml, but I still get the error. I don’t know what it is. Does anyone can help?

thanks

The error:

    FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{br.com.controladoratividades/br.com.controladoratividades.activities.NovaAtividadeActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.content.ContextWrapper.getResources(ContextWrapper.java:80)
at android.content.Context.getString(Context.java:182)
at br.com.controladoratividades.activities.NovaAtividadeActivity.<init>(NovaAtividadeActivity.java:15)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1429)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
... 11 more

My AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="br.com.controladoratividades"
    android:versionCode="1"
    android:versionName="1.0" >



    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".activities.ControladorAtividadesActivity"
            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=".activities.NovaAtividadeActivity"
            android:label="@string/nova_atividade" >            
        </activity>

           <activity
            android:name=".activities.PlanejadorActivity"
            android:label="@string/novo_plano" >            
        </activity>         


    </application>

    <uses-sdk android:minSdkVersion="7" />

</manifest>

The activity:

package br.com.controladoratividades.activities;

import br.com.controladoratividades.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class NovaAtividadeActivity extends Activity {

    private String[] DIAS = new String[] {getString(R.string.domingo), 
            getString(R.string.segunda),
            getString(R.string.terca),
            getString(R.string.quarta),
            getString(R.string.quinta),
            getString(R.string.sexta),
            getString(R.string.sabado)};
    protected boolean[] DIAS_SELECIONADOS =  new boolean[ DIAS.length ];

    static final int DIAS_DIALOG_ID = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.nova_atividade);

        Button btAlterarDias = (Button)findViewById(R.id.btSalvarPlano);
        btAlterarDias.setOnClickListener(new AlterarDiasClickHandler());

        for (int i = 1;  i < DIAS_SELECIONADOS.length; i++) {
            DIAS_SELECIONADOS[i] = true;
        }
    }

    public class AlterarDiasClickHandler implements View.OnClickListener{

        @Override
        public void onClick(View v) {
            showDialog(DIAS_DIALOG_ID);

        }       
    }

    @Override
    protected Dialog onCreateDialog( int id ) 
    {
        return 
        new AlertDialog.Builder( this )
            .setTitle( "Planets" )
            .setMultiChoiceItems( 
                    DIAS,
                    DIAS_SELECIONADOS, 
                    new DialogSelectionClickHandler() )
            .setPositiveButton( "OK", new DialogButtonClickHandler() )
            .create();
    }

    public class DialogSelectionClickHandler implements DialogInterface.OnMultiChoiceClickListener
    {
        public void onClick( DialogInterface dialog, int clicked, boolean selected )
        {
            Log.i( "ME", DIAS[ clicked ] + " selected: " + selected );
        }
    }

    public class DialogButtonClickHandler implements DialogInterface.OnClickListener
    {
        public void onClick( DialogInterface dialog, int clicked )
        {
            switch( clicked )
            {
                case DialogInterface.BUTTON_POSITIVE:
                    //printSelectedPlanets();
                    break;
            }
        }
    }
}
  • 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-05T18:23:47+00:00Added an answer on June 5, 2026 at 6:23 pm

    We don’t have any code to confirm, but the error seems to suggest that you are trying to use getString from within NovaAtividadeActivity‘s constructor. An Activity is not created until the onCreate call, so you would have to move your code from the constructor to that function.

    Update: Now that you added the code for the activity, we can see that you are calling getString to initialize the member DIAS, which will happen at the class’ constructor. Instead, move the initialization of DIAS to onCreate.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.