Search Unity

Android - App stops responding because of activity plugin in front of Unity player [EDITED]

Discussion in 'Android' started by Augality, Feb 2, 2015.

  1. Augality

    Augality

    Joined:
    Aug 4, 2014
    Posts:
    14
    Hi everyone

    In further research of creating a Android Plugin myself with a manifest that already uses other plugins, I once again stumbled upon a problem.
    I don't have anymore errors, but it seems that touch inputs don't work anymore.

    It's like there is an invisible layer on top of the unity layer, that prevents touches from being registered.
    This is how the activity looks like in the manifest for the moment:
    Code (CSharp):
    1.  
    2. <activity android:name="com.kristofvdh.ibeacon.BeaconScanActivity"
    3.   android:label="@string/app_name"
    4.   android:hardwareAccelerated="true"
    5.   android:theme="@android:style/Theme.Translucent.NoTitleBar"
    6.   android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    7.   <intent-filter>
    8.   <action android:name="android.intent.action.MAIN" />
    9.   </intent-filter>
    10.   <meta-data android:name="android.app.lib_name" android:value="unity" />
    11.   <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
    12.   </activity>
    13.  
    I tried several things: With the label, theme, etc...; Without them; With intent-filter, Without it;...
    If someone had the same problem and knows the solution, please provide the answer here.
    I'm struggling for a long time now, it's harder than I thought.

    I'll also attach the full manifest in this post.
    Thanks in advance.

    P.S.:
    Click here for previous thread.
     

    Attached Files:

  2. Augality

    Augality

    Joined:
    Aug 4, 2014
    Posts:
    14
    No one had this problem before?
     
  3. Augality

    Augality

    Joined:
    Aug 4, 2014
    Posts:
    14
    It seems that the activity is on top of the unity player and freezes it (app not responding anymore). When I start a coroutine with a message every second, it won't show up. Hope this info helps me and others to find the solution.
     
  4. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    530
    Is BeaconScanActivity a NativeActivity?
     
  5. Augality

    Augality

    Joined:
    Aug 4, 2014
    Posts:
    14
    Well, I tried all kinds: Activity, UnityPlayerActivity and UnityPlayerNativeActivity, but all 3 of them seem to result in the same outcome.
     
  6. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    530
    Oh, I just checked your manifest file. You have two Unity activities in there? That's not going to work. You can only have one Unity Activity per process.
     
  7. Augality

    Augality

    Joined:
    Aug 4, 2014
    Posts:
    14
    Ow :s so I cannot use multiple android plugins (activities) in one app? That's a bummer.
     
  8. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    530
    Well, you can, as long as the plugins doesn't require a unique instance of Unity. To be honest I'm not exactly sure what it is you are trying to do here. I mean, what is it you are trying to achieve by having two separate Activities which both are running an instance of the Unity player? Or are you trying to share the instance between two Activity instances?
     
  9. Augality

    Augality

    Joined:
    Aug 4, 2014
    Posts:
    14
    Well, the first plugin isn't mine, it's one that is bought and opens a webview. The iBeacon one is mine and I want to use them both in my app.

    The iBeacon app just has to give me all beacons near the device and other usefull info.
    So I managed to start my activity by using AndroidJavaObject/Class and also want to call my methods with it. But I stuck there, because it doesn't respond.

    Does this info help you?
    How can I start the second Activity and use its methods without problems?

    Btw, thanks for taking the time to help.
     
  10. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    530
    Maybe a silly question but why do you need an Activity to get the beacons? If you start another Activity what normally happens on Android is that the current activity gets paused. Meaning if you start an Activity from inside Unity, Unity will get paused while that Activity is in play. Once that Activity quits Unity will resume execution. It doesn't necessarily have to be like this but that's sort of the standard way Android works.

    Some useful information on activities:
    http://developer.android.com/guide/components/tasks-and-back-stack.html
    http://developer.android.com/training/basics/activity-lifecycle/index.html

    That being said, in your case I don't really see a need for an Activity at all (although I know very little of the implementation details). Can't you just write a regular java class that look up the beacons?
     
  11. Augality

    Augality

    Joined:
    Aug 4, 2014
    Posts:
    14
    Ow, OK that makes sense. Well, I guess I thought I had to make an activity in order to make it work with Unity. But now you pointed out that this is not necessary, I'll give it a go as a normal class.

    Thank you very much for the info, it is really helpful!
     
  12. MarkMMullin

    MarkMMullin

    Joined:
    Apr 23, 2015
    Posts:
    3
    OK, so I have googles cardboard loaded, and need to define an activity that can handle interaction with google speech - I appreciate the issue with activity lifecycle, however this seems to read as the unity activity wins and everyone else looses - how do the Unity folks recommend we deal with these issues - Unity + cardboard + speech is a good thing - Unity + cardboard + OnGui is stupid at best, and on a Durovis Dive 7 helmet is of negative value. I realize I could probably subclass the cardboard activity, but then these extensions become way too specific, i.e. they have to constantly subclass a known activity - right now, at least in terms of what's in the asset store, you can have cardboard, or you can have speech, but I cannot see how to get both :-(
     
  13. eppz

    eppz

    Joined:
    Aug 2, 2014
    Posts:
    172