Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by smtabatabaie · Feb 03, 2015 at 07:57 AM · androidvuforianativeeclipse

launch android activity from unity

Hi , I have an android app which by pressing a button it should get me to the AR scene built in unity3d and vuforia.

I have made my AR project in unity and exported it to eclipse and then added other activities to it.

when I press the button I do this code :

Intent intent= new Intent(getApplicationContext(), QCARPlayerNativeActivity.class); startActivity(intent);

and the app goes to the AR scene. Now I want to be able to go back to the normal activity which has the button. I tried pressing back but it didn't work I also found this page : http://stackoverflow.com/questions/7754373/integrating-unity-with-eclipse-back-button-click And I tried to use it but again no luck. I think it doesn't work because I go to QCARPlayerNativeActivity class but I don't have any access to this class to override its onBackPressed() function. I'll appreciate if you can help me with this. Thanks very much

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by steakpinball · Feb 03, 2015 at 04:15 PM

The code you have for launching the Unity scene is good. The problem is the unity activity doesn't watch for the back button press. Since you can't modify the QCAR activity to finish, you can do it from inside your unity scene.

In your Unity scene you can have a script looking for a back button press. The back button looks like the escape key to Unity. Quitting the Unity activity will return you to the previous activity. Application.Quit() finishes the activity returning you to the activity which launched it.

 void Update() {
   if (Input.GetKeyDown(KeyCode.Escape)) {
     Application.Quit();
   }
 }
Comment
Add comment · Show 2 · Share
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 smtabatabaie · Feb 03, 2015 at 04:17 PM 0
Share

Thanks $$anonymous$$ but doing so will get you out of the application, I want to launch another activity

avatar image steakpinball · Feb 03, 2015 at 04:40 PM 0
Share

This unity code is equivalent to the android code linked in the question.

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.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Different approaches to Android plugins 0 Answers

How do I set up an Android device for Build & Run? 9 Answers

No staging area folder 1 Answer

[Android+Eclipse]Get album image from mp3 file 0 Answers

Screenshot function not working properly ,it records button on UI ? 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