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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:51:39+00:00 2026-06-08T11:51:39+00:00

Here is the code I use to bring up the activity: startActivity(new Intent(getApplicationContext(), Giveaway.class));

  • 0

Here is the code I use to bring up the activity:

startActivity(new Intent(getApplicationContext(), Giveaway.class)); 

Here is the Activity that I am bringing up:

public class Giveaway extends Activity implements OnClickListener{

static SharedPreferences settings;
SharedPreferences.Editor prefEditor;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.giveaway);

    settings = getSharedPreferences("firsttime", 0);

    LinearLayout facebook = (LinearLayout)findViewById(R.id.facebooklayout);
    Button later = (Button)findViewById(R.id.later);
    Button dontshowagain = (Button)findViewById(R.id.dontshowagain);

    facebook.setOnClickListener(this);
    later.setOnClickListener(this);
    dontshowagain.setOnClickListener(this);

}

public void onClick(View v) {
    switch (v.getId()) {
    case R.id.facebooklayout:
        Uri localuri = Uri.parse("http://www.facebook.com/pages/Bright-Design/366832480049386");
        startActivity(new Intent("android.intent.action.VIEW", localuri));
        break;
    case R.id.later:
        finish();
        break;
    case R.id.dontshowagain:
        finish();
        prefEditor = settings.edit();
        prefEditor.putBoolean("showgiveaway", false);
        prefEditor.commit();
        break;
    }
}

I have declared the Activity in my manifest folder:

<activity
        android:name=".Giveaway"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Dialog"
        android:screenOrientation="portrait"/>

But I keep getting a java.lang.RuntimeException: Unable to start activity java.lang.NullPointerException error. Here is my logcat:

    07-24 12:43:59.082: E/AndroidRuntime(7039): FATAL EXCEPTION: main
07-24 12:43:59.082: E/AndroidRuntime(7039): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.brightdesign.blackops2/com.brightdesign.blackops2.Giveaway}: java.lang.NullPointerException
07-24 12:43:59.082: E/AndroidRuntime(7039):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-24 12:43:59.082: E/AndroidRuntime(7039):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-24 12:43:59.082: E/AndroidRuntime(7039):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-24 12:43:59.082: E/AndroidRuntime(7039):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-24 12:43:59.082: E/AndroidRuntime(7039):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-24 12:43:59.082: E/AndroidRuntime(7039):     at android.os.Looper.loop(Looper.java:123)
07-24 12:43:59.082: E/AndroidRuntime(7039):     at android.app.ActivityThread.main(ActivityThread.java:4627)
07-24 12:43:59.082: E/AndroidRuntime(7039):     at java.lang.reflect.Method.invokeNative(Native Method)
07-24 12:43:59.082: E/AndroidRuntime(7039):     at java.lang.reflect.Method.invoke(Method.java:521)
07-24 12:43:59.082: E/AndroidRuntime(7039):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-24 12:43:59.082: E/AndroidRuntime(7039):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-24 12:43:59.082: E/AndroidRuntime(7039):     at dalvik.system.NativeStart.main(Native Method)
07-24 12:43:59.082: E/AndroidRuntime(7039): Caused by: java.lang.NullPointerException
07-24 12:43:59.082: E/AndroidRuntime(7039):     at com.brightdesign.blackops2.Giveaway.onCreate(Giveaway.java:29)
07-24 12:43:59.082: E/AndroidRuntime(7039):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-24 12:43:59.082: E/AndroidRuntime(7039):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  • 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-08T11:51:42+00:00Added an answer on June 8, 2026 at 11:51 am

    You need to post your layout code, but what is most likely happening is that one of these three lines is returning a null value:

    LinearLayout facebook = (LinearLayout)findViewById(R.id.facebooklayout);
    Button later = (Button)findViewById(R.id.later);
    Button dontshowagain = (Button)findViewById(R.id.dontshowagain);
    

    In the debugger step through those lines and if one is null, there is your problem because as soon as you try to set the on click listener it is going to fail.

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

Sidebar

Related Questions

Here's sample model classes, which being use with Entity Framework Code First: public class
Here is a code I use : request.jsf <h:form> <!-- form inputs ... -->
Here's the code I use to load a texture. image is a CGImageRef. After
Here is the code I use to draw: - (void) drawSomething { CGContextRef context
Here is the code I use to define my array, this code is above
Here is the code I use when someone visits a product page on my
Here is the javascript code I use to create the array and send it
Here is a simplified version of the code I use. I need to rewrite
I'm trying to use the SQLite rawQuery method, based on the code here: Android
Here is my code #!usr/bin/env perl # Setup includes use strict; use XML::RSS; use

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.