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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:44:54+00:00 2026-06-02T05:44:54+00:00

I really can’t get my head around Activity, Intent and start.. even after reading

  • 0

I really can’t get my head around Activity, Intent and start.. even after reading Lars Vogels Tutorial (Tutorial on Intents)

I’ve tried to make the question as clean and simple as possible.

2 classes (KKOTestActivity, VersionChangeInfo) and one AndroidManifest.

Goal : Class KKOTestActivity starts, fires off VersionChangeInfo. That class shows a dialog with three buttons. One of them is the go-to-market. That’s where the problem is. When the user presses that button, I get NPE Error (see error log below). I really don’t understand what I’m doing here, so a link to Intents-for-dummies or something would also be highly appreciated :). Thanks!

KKOTestActivity :

package happyworx.nl.KKOTest;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;


public class KKOTestActivity extends Activity implements OnClickListener {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        new VersionChangeInfo(this).show();
    }
    public void onClick(View v) {
        // TODO Auto-generated method stub  
    }
}

VersionChangeInfo.java :

package happyworx.nl.KKOTest;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.preference.PreferenceManager;


public class VersionChangeInfo extends Activity {

    private String VCI_PREFIX = "vci_";
    private Activity mActivity;

    public VersionChangeInfo(final Activity context) {
        mActivity = context;
    }

    private PackageInfo getPackageInfo() {
        PackageInfo pi = null;
        try {
             pi = mActivity.getPackageManager().getPackageInfo(mActivity.getPackageName(), PackageManager.GET_ACTIVITIES);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return pi;
    }

     public void show() {
        PackageInfo versionInfo = getPackageInfo();

        // the eulaKey changes every time you increment the version number in the AndroidManifest.xml
        final String eulaKey = VCI_PREFIX + versionInfo.versionCode;
        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
        boolean hasBeenShown = prefs.getBoolean(eulaKey, false);
        if(hasBeenShown == false){

            // Show the Eula
            String title = mActivity.getString(R.string.app_name) + " v" + versionInfo.versionName;

            //Includes the updates as well so users know what changed.
            String message = mActivity.getString(R.string.updates) + "\n\n" + mActivity.getString(R.string.eula);

            AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
                    .setTitle(title)
                    .setMessage(message)
                    .setPositiveButton("Ga naar Market", new Dialog.OnClickListener() {

                        public void onClick(DialogInterface dialogInterface, int i) {                           
                            // Mark this version as read.
                            SharedPreferences.Editor editor = prefs.edit();
                         //   editor.putBoolean(eulaKey, true);
                         //   editor.commit();
                            dialogInterface.dismiss();

                            final Intent MyIntent = new Intent(Intent.ACTION_VIEW, 
                            Uri.parse("market://details?id=happyworx.nl.Flashwords"));
                            startActivity(MyIntent);
                        }
                    })
                    .setNegativeButton("Later", new Dialog.OnClickListener() {

                        public void onClick(DialogInterface dialogInterface, int i) {
                            dialogInterface.dismiss();
                        }



                    })

                    .setNeutralButton("Niet meer tonen", new Dialog.OnClickListener(){
                        public void onClick(DialogInterface dialogInterface, int i) {
                            SharedPreferences.Editor editor = prefs.edit();
                            editor.putBoolean(eulaKey, true);
                            editor.commit();
                            dialogInterface.dismiss();
                        }
                    })
                    ;
            builder.create().show();
        }
    }

}

AndroidManifest.xls

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

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

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".KKOTestActivity"
            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=".VersionChangeInfo"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>

Error Log :

04-19 08:06:45.711: E/AndroidRuntime(15186): FATAL EXCEPTION: main
04-19 08:06:45.711: E/AndroidRuntime(15186): java.lang.NullPointerException
04-19 08:06:45.711: E/AndroidRuntime(15186):    at android.app.Activity.startActivityForResult(Activity.java:2827)
04-19 08:06:45.711: E/AndroidRuntime(15186):    at android.app.Activity.startActivity(Activity.java:2933)
04-19 08:06:45.711: E/AndroidRuntime(15186):    at happyworx.nl.KKOTest.VersionChangeInfo$1.onClick(VersionChangeInfo.java:63)
04-19 08:06:45.711: E/AndroidRuntime(15186):    at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159)
04-19 08:06:45.711: E/AndroidRuntime(15186):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-19 08:06:45.711: E/AndroidRuntime(15186):    at android.os.Looper.loop(Looper.java:123)
04-19 08:06:45.711: E/AndroidRuntime(15186):    at android.app.ActivityThread.main(ActivityThread.java:3683)
04-19 08:06:45.711: E/AndroidRuntime(15186):    at java.lang.reflect.Method.invokeNative(Native Method)
04-19 08:06:45.711: E/AndroidRuntime(15186):    at java.lang.reflect.Method.invoke(Method.java:507)
04-19 08:06:45.711: E/AndroidRuntime(15186):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-19 08:06:45.711: E/AndroidRuntime(15186):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-19 08:06:45.711: E/AndroidRuntime(15186):    at dalvik.system.NativeStart.main(Native Method)
  • 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-02T05:44:56+00:00Added an answer on June 2, 2026 at 5:44 am

    First, you’re missing a <action android:name="android.intent.action.VIEW" /> in your AndroidManifest.xml, inside the <intent-filter>.

    But when this’ll be done, it’ll crash anyways, because the Market is not installed on the emulator. It should work fine on a device though.

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

Sidebar

Related Questions

I really can'get my head around why the following happens: Double d = 0.0;
I really can't wrap my mind around this: Previously I couldn't get Framebuffers to
I have 2 major problems with the Flex (4.6) SoapDecoder, I really can't get
i do get an Integrity constraint violation for Doctrine though i really can't see
I saw the following namespace implementation in an article and i really can't get
I've read lots of articles about intent filters and I really can't understand exactly
I know this subject was discussed here, but I really can't get this to
I really can't seem to get the hang of Model objects in MVC. I
I'm tired and I can't wrap my head around this. I have two tables:
I really can't solve this problem and don't even know, if it is possible.

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.