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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:58:01+00:00 2026-05-27T04:58:01+00:00

package com.org.myOxygen.activities; import java.util.Stack; import android.app.Activity; import android.app.ActivityGroup; import android.app.LocalActivityManager; import android.content.Intent; import android.os.Bundle;

  • 0
package com.org.myOxygen.activities;

import java.util.Stack;

import android.app.Activity;
import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;

public class ApplicationTabActivityGroup extends ActivityGroup{

private static Stack<String> stack;

 @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (stack == null) stack = new Stack<String>();
    
    //start default activity
    push("Search Activity", new Intent(this, ApplicaitonActivity.class));
    
  }

  @Override
  public void finishFromChild(Activity child) {
      
          pop();
  }

  @Override
  public void onBackPressed() 
  {
      
          pop();
  }


  public void push(String id, Intent intent) 
  {
    Window window = getLocalActivityManager().startActivity(id, intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
    if (window != null) {
      stack.push(id);
      setContentView(window.getDecorView());
    }
  }

  public void pop() 
  {
    if (stack.size() == 1) finish();
    LocalActivityManager manager = getLocalActivityManager();
    
    manager.destroyActivity(stack.pop(), true);
    
    if (stack.size() > 0) 
    {
      Intent lastIntent = manager.getActivity(stack.peek()).getIntent();
      Window newWindow = manager.startActivity(stack.peek(), lastIntent);
      setContentView(newWindow.getDecorView());
    }
  }

}

I am getting error on line

Intent lastIntent = manager.getActivity(stack.peek()).getIntent();

The error is NullPointerException.

What might be wrong there?

edit – 1

  11-26 14:58:57.256: E/AndroidRuntime(557): FATAL EXCEPTION: main
11-26 14:58:57.256: E/AndroidRuntime(557): java.lang.NullPointerException
11-26 14:58:57.256: E/AndroidRuntime(557):  at com.org.myOxygen.activities.SearchTabActivityGroup.pop(SearchTabActivityGroup.java:59)
11-26 14:58:57.256: E/AndroidRuntime(557):  at com.org.myOxygen.activities.SearchTabActivityGroup.onBackPressed(SearchTabActivityGroup.java:36)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.app.Activity.onKeyUp(Activity.java:1888)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.view.KeyEvent.dispatch(KeyEvent.java:1061)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.app.Activity.dispatchKeyEvent(Activity.java:2068)
11-26 14:58:57.256: E/AndroidRuntime(557):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1643)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.widget.TabHost.dispatchKeyEvent(TabHost.java:275)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
11-26 14:58:57.256: E/AndroidRuntime(557):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1667)
11-26 14:58:57.256: E/AndroidRuntime(557):  at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1102)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.app.Activity.dispatchKeyEvent(Activity.java:2063)
11-26 14:58:57.256: E/AndroidRuntime(557):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1643)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2471)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2441)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1735)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.os.Looper.loop(Looper.java:123)
11-26 14:58:57.256: E/AndroidRuntime(557):  at android.app.ActivityThread.main(ActivityThread.java:4627)
11-26 14:58:57.256: E/AndroidRuntime(557):  at java.lang.reflect.Method.invokeNative(Native Method)
11-26 14:58:57.256: E/AndroidRuntime(557):  at java.lang.reflect.Method.invoke(Method.java:521)
11-26 14:58:57.256: E/AndroidRuntime(557):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-26 14:58:57.256: E/AndroidRuntime(557):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-26 14:58:57.256: E/AndroidRuntime(557):  at dalvik.system.NativeStart.main(Native Method)

Here is the stack trace!

  • 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-27T04:58:02+00:00Added an answer on May 27, 2026 at 4:58 am

    By looking at your code I have found one reason which can create the NullPointerException and that is,
    may be you are using method “public void push(String id, Intent intent)” with the same id(String) for diffrent activity.

    reason why it creates null pointer exception is, when you call push method with same id(String) and Android mamory managemnt destroy the old activity associated with that name and during your pop method it returns null.

    Hope this answer helps to solve bug.

    Cheers,
    Viraj

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

Sidebar

Related Questions

package com.rest; import java.io.IOException; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button;
package com.android.project; import android.app.Activity; import android.os.Bundle; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE;
aka, what is wrong with this code:- package com.mez.appofjaq; import com.mez.appofjaq.RssParser.RssFeed; import android.app.Activity; import
1st activity package com.example.parserss; import java.net.URL; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.InputSource; import org.xml.sax.XMLReader;
package com.owen.quartergames.dao; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document;
this is my nodefinder.java file package com.acme.web.action.executer; import java.sql.ResultSet; import java.util.Map; import org.alfresco.web.bean.repository.Node; import
i have the following action class: package com.pendulum.web; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest;
Here are my hibernate classes package com.vaannila.domain; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import
Code: package com.parse; import org.w3c.dom.*; import javax.xml.xpath.*; import javax.xml.parsers.*; import java.io.IOException; import org.xml.sax.SAXException; public
I'm using this mapper created by Ikai Lan: package com.ikai.mapperdemo.mappers; import java.util.Date; import java.util.logging.Logger;

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.