• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Polona · Jun 29, 2015 at 12:36 PM · androidunity 5

Android app crashes when launching a second UnityPlayerActivity from Unity5

I'm trying to launch a second UnityPlayerActivity from Unity5. I saw this very similar question Launch Activity from Unity Activity

Still, it doesn't work with my code in Eclipse and Unity5.

Code in Unity:

 AndroidJavaClass ajc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
 AndroidJavaObject ajo = ajc.GetStatic<AndroidJavaObject>("currentActivity");
 
 // Accessing the pulse class to call a static method on it.
 AndroidJavaClass overrideExample = new AndroidJavaClass("pulse.OverrideExample2");
 overrideExample.CallStatic("startOverrideExample", ajo);


Java code:

 public class OverrideExample2 extends UnityPlayerActivity {
 
     protected void onCreate(Bundle savedInstanceState) {
         // call UnityPlayerActivity.onCreate()
         super.onCreate(savedInstanceState);
 
         // print debug message to logcat
         Log.d("OverrideExample2", "onCreate called!");
     }
 
     public void onBackPressed() {
         // instead of calling UnityPlayerActivity.onBackPressed() we just ignore
         // the back button event
         // super.onBackPressed();
     }
     
     public static void startOverrideExample(Activity activity) {
         // Creating an intent with the current activity and the activity we wish to start
         Intent myIntent = new Intent(activity, OverrideExample2.class);
         activity.startActivity(myIntent);
     }
     
 }

OverrideExample2 class will be created. But then the app crashes. I'm getting following errors:

 06-29 13:53:59.973: D/OverrideExample2(16788): onCreate called!
 06-29 13:53:59.978: V/WindowManager(724): Adding window Window{2d9b0e5b u0 com.Company.UHG/pulse.OverrideExample2} at 5 of 11 (after Window{238b26b0 u0 com.Company.UHG/pulse.OverrideExample})
 06-29 13:54:00.011: V/WindowManager(724): Adding window Window{1aadb7d1 u0 SurfaceView} at 5 of 12 (before Window{2d9b0e5b u0 com.Company.UHG/pulse.OverrideExample2})
 06-29 13:54:00.027: A/libc(16788): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x50 in tid 16845 (UnityMain)
 06-29 13:54:00.027: I/libc(16788): Suppressing debuggerd output because prctl(PR_GET_DUMPABLE)==0
 06-29 13:54:00.031: I/ActivityManager(724): Displayed com.Company.UHG/pulse.OverrideExample2: +72ms
 06-29 13:54:00.060: W/InputDispatcher(724): channel '238b26b0 com.Company.UHG/pulse.OverrideExample (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
 06-29 13:54:00.060: E/InputDispatcher(724): channel '238b26b0 com.Company.UHG/pulse.OverrideExample (server)' ~ Channel is unrecoverably broken and will be disposed!
 06-29 13:54:00.070: W/InputDispatcher(724): channel '2d9b0e5b com.Company.UHG/pulse.OverrideExample2 (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
 06-29 13:54:00.070: E/InputDispatcher(724): channel '2d9b0e5b com.Company.UHG/pulse.OverrideExample2 (server)' ~ Channel is unrecoverably broken and will be disposed!
 06-29 13:54:00.083: I/Zygote(200): Process 16788 exited due to signal (11)
 06-29 13:54:00.087: I/WindowState(724): WIN DEATH: Window{238b26b0 u0 com.Company.UHG/pulse.OverrideExample}
 06-29 13:54:00.087: W/InputDispatcher(724): Attempted to unregister already unregistered input channel '238b26b0 com.Company.UHG/pulse.OverrideExample (server)'
 06-29 13:54:00.088: I/WindowState(724): WIN DEATH: Window{2ddd8dba u0 SurfaceView}
 06-29 13:54:00.090: I/WindowState(724): WIN DEATH: Window{2d9b0e5b u0 com.Company.UHG/pulse.OverrideExample2}
 06-29 13:54:00.090: W/InputDispatcher(724): Attempted to unregister already unregistered input channel '2d9b0e5b com.Company.UHG/pulse.OverrideExample2 (server)'
 06-29 13:54:00.091: I/WindowState(724): WIN DEATH: Window{1aadb7d1 u0 SurfaceView}
 06-29 13:54:00.102: I/ActivityManager(724): Process com.Company.UHG (pid 16788) has died

If i try to launch OverrideExample2 class as a MainActivity, then it works. But i want to use multiple Activities in my project.

Please help!

Comment

People who like this

0 Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image bbetter · Nov 18, 2015 at 02:39 PM 0
Share

please , did you manage to solve this issue?

avatar image Polona bbetter · Nov 19, 2015 at 06:58 AM 0
Share

Sorry, i did not manage to solve this issue. I rewrote my code, so that i use only one activity.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Android touch input Null Reference exception error 0 Answers

Cannot open database connection in android.. 0 Answers

My text don't appear in Game Window, help 1 Answer

Pink custom shader on Android build 0 Answers

Unity Ads can not show more than 1 time after install game 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges