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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:45:45+00:00 2026-06-01T14:45:45+00:00

how to make android 2.2 app work in android 4 ? Is it a

  • 0

how to make android 2.2 app work in android 4 ?
Is it a great refactoring work? or is it just some sdk settings to change in the project?

BTW : which the better case :
– adapted android 2.2 app that will work with android 4 ?
– android 4 app with compatibility package from google ?

Thanks in advance?

EDIT:
I ask this because my app runs fine in android 2.2 and 2.3 but crashes in android 4.

StackTrace :

E/AndroidRuntime(  660): FATAL EXCEPTION: main
E/AndroidRuntime(  660): java.lang.RuntimeException: Unable to start activity ComponentInfo{vex.android/vex.android.controllers.ControllerLoginView}: java.lang.NullPointerException
E/AndroidRuntime(  660):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
E/AndroidRuntime(  660):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime(  660):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime(  660):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime(  660):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  660):    at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(  660):    at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime(  660):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  660):    at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(  660):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(  660):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(  660):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(  660): Caused by: java.lang.NullPointerException
E/AndroidRuntime(  660):    at vex.android.layout.layout_titleheader.setButtonVisibility(layout_titleheader.java:163)
E/AndroidRuntime(  660):    at vex.android.layout.layout_titleheader.setButtonVisibility(layout_titleheader.java:155)
E/AndroidRuntime(  660):    at vex.android.controllers.ControllerLoginView.Initialize(ControllerLoginView.java:58)
E/AndroidRuntime(  660):    at vex.android.definition.VexActivity.onStart(VexActivity.java:154)
E/AndroidRuntime(  660):    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1133)
E/AndroidRuntime(  660):    at android.app.Activity.performStart(Activity.java:4475) 
E/AndroidRuntime(  660):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1929)
E/AndroidRuntime(  660):    ... 11 more

layout_titleheader.java :

    package vex.android.layout;

    import vex.android.R;
    import vex.android.controllers.ControllerInfo;
    import vex.android.definition.VexLayout;
    import vex.android.definition.iVexParentable;
    import vex.android.definition.intentCode;
    import android.app.Activity;
    import android.app.Instrumentation;
    import android.content.Context;
    import android.content.Intent;
    import android.os.Handler;
    import android.os.SystemClock;
    import android.util.AttributeSet;
    import android.view.KeyEvent;
    import android.view.MotionEvent;
    import android.view.View;
    import android.widget.Button;
    import android.widget.ImageButton;
    import android.widget.ImageView;


    public class layout_titleheader extends VexLayout
    {
        /*** CONTROL POINTERS ***/
        Button nextButton;
        Button prevButton;
        ImageView infoButton;
        ImageButton upButton;
        ImageButton downButton;

        private Handler handler = new Handler(); 
        private Runnable upTask = new Runnable() { 
            public void run() {
                if(getContext() instanceof iVexParentable) {
                    ((iVexParentable)getContext()).onUpButton();
                }
                handler.postAtTime(this, SystemClock.uptimeMillis() +  100); 
            } 
        };
        private Runnable downTask = new Runnable() { 
            public void run() {
                if(getContext() instanceof iVexParentable) {
                    ((iVexParentable)getContext()).onDownButton();
                }
                handler.postAtTime(this, SystemClock.uptimeMillis() +  100); 
            } 
        };

        /**** CONSTRUCTORS ****/
        public layout_titleheader(Context context)
        {
            super(context);
            ((Activity)getContext()).getLayoutInflater().inflate(R.layout.layout_titleheader, this);
        }
        public layout_titleheader(Context context, AttributeSet attrs) {
            super(context, attrs);
            ((Activity)getContext()).getLayoutInflater().inflate(R.layout.layout_titleheader, this);
        }

        /**** INITIALIZERS ****/
        @Override
        public void Initialize()
        {
            infoButton.setOnTouchListener(new OnTouchListener(){
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if(event.getAction() == MotionEvent.ACTION_DOWN) 
                    {
                        showInfo();
                    }
                    return true;
                }
            });

            prevButton.setOnTouchListener(new OnTouchListener(){
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if(event.getAction() == MotionEvent.ACTION_DOWN)
                    {
                        new Thread(new Runnable() {
                            @Override
                            public void run() {
                                Instrumentation i = new Instrumentation();
                                i.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
                            }
                        }).start();
                    }
                    return true;
                }
            });

            nextButton.setOnTouchListener(new OnTouchListener(){
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if(event.getAction() == MotionEvent.ACTION_DOWN)
                    {
                        if(getContext() instanceof iVexParentable)
                        {
                            ((iVexParentable)getContext()).onEditButton();
                        }
                    }
                    return true;
                }
            });
            upButton.setOnTouchListener(new OnTouchListener() {
                public boolean onTouch(View view, MotionEvent motionevent) {
                    int action = motionevent.getAction();
                    if (action == MotionEvent.ACTION_DOWN) {
                        handler.removeCallbacks(upTask);
                        handler.postAtTime(upTask, SystemClock.uptimeMillis() + 100);
                    } else if (action == MotionEvent.ACTION_UP) {
                        handler.removeCallbacks(upTask);
                    }
                    return false;
                }
            });

            downButton.setOnTouchListener(new OnTouchListener(){
                @Override
                public boolean onTouch(View v, MotionEvent motionevent) {
                    int action = motionevent.getAction();
                    if (action == MotionEvent.ACTION_DOWN) {
                        handler.removeCallbacks(downTask);
                        handler.postAtTime(downTask, SystemClock.uptimeMillis() + 100);
                    } else if (action == MotionEvent.ACTION_UP) {
                        handler.removeCallbacks(downTask);
                    }
                    return false;
                }
            });
        }

        @Override
        public void InitializeControls()
        {
            infoButton = (ImageView)findViewById(R.id.infoButton);
            prevButton = (Button)findViewById(R.id.prevButton);
            nextButton = (Button)findViewById(R.id.nextButton);
            upButton = (ImageButton)findViewById(R.id.upButton);
            downButton = (ImageButton)findViewById(R.id.downButton);
        }

        /**** LOCAL METHODS ****/
        public void showInfo()
        {
            if(getContext() instanceof Activity)
            {
                Intent intent = new Intent(getContext(), ControllerInfo.class);
                ((Activity)getContext()).startActivityForResult(intent, intentCode.INFO_DOSTART);
            }
        }
        public void setButtonVisibility( int previousButton, int editButton, int helpButton)
        {
            setButtonVisibility(previousButton, editButton, helpButton, View.INVISIBLE, View.INVISIBLE);
        }

        public void setButtonVisibility( int previousButton, int editButton, int helpButton, int upButtonVisibility, int downButtonVisibility)
        {
            if (View.VISIBLE == previousButton) {// fixes issue of translation not correctly displayed
                prevButton.setText(getContext().getString(R.string.Back));
            }
            prevButton.setVisibility(previousButton);
            nextButton.setVisibility(editButton);
            infoButton.setVisibility(helpButton);
            upButton.setVisibility(upButtonVisibility);
            downButton.setVisibility(downButtonVisibility);
        }

        public void setPreviousButtonText(int id) {
            prevButton.setText(getContext().getString(id));
        }

        public void setEditButtonName(int resId)
        {
            nextButton.setText(resId);
        }
    }

After some digging, I found that onFinishInflate() from View class that is overriden in VexLayout is NOT called when running android 4. Any idea?

  • 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-01T14:45:47+00:00Added an answer on June 1, 2026 at 2:45 pm

    Android platform is generally forward-compatible. It means that you can write your app for SDK 8 (2.2) and it will run on 4.0.

    UPDATE:
    Try to check whether one of Views(for example prevButton or nextButton) equals null, getContext or Context.getString(int)returns null in method
    setButtonVisibility(int, int, int, int, int)

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

Sidebar

Related Questions

I've been asked for some review copies of an Android app I've written, which
I want to make an Android Game App that loads a game slot that
I would like to make a single Android app for multiple Android versions (possibly
I want to make an App Engine connected Android app, and I'm beginning with
I want to make a menu in my android app but I don't want
I am new android app developer i want make app for tablets and phone
I have to make a peer to peer file sharing app on android platform
I am trying to make App Distribution from Facebook for android apps. But the
How to make android EditText smaller than default in height? If I change the
So here's some code on http://groups.google.com/group/android-developers/browse_thread/thread/16a2216b39513674 in which the poster writes that he's shortened

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.