Topic locked

After updating sdk to vuforia-unity-android-ios-3-0-9 from 2-8-9 for Android sub view have no respond to touch

December 23, 2014 - 2:31am #1

Hi

I was using Untiy 4.2.1 and vuforia-unity-android-ios version 2-8-9 earlier for Android sub view integration and ait was working fine. Now I have updated unity to 4.6.1 and vuforia sdk to 3.0.9 and now Android subview have no respond to touch.

Actually first I have updated unity from 4.2.1 to 4.6.1 and exported to android then installed in device. Weird behaviour, display from ARCamera view was dark black but I were still able to scan markers and touch was working fine till this time.

Then I have updated vuforia unity sdk to 3.0.9 extension and exported again to android. ARCamera has no dark black display issue but my device is not able to handle touch.

 

I have followed the instruction https://developer.vuforia.com/resources/dev-guide/extending-unity-android-activity-and-adding-custom-views-eclipse to integrate Unity with Eclipse and installed on device. I have also went through similar issue of someone https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/added-android-sub-view-have-no-respond-touch&sort=2 and it is helpless because integration guide is changed.

 

Do I missed something important causing this problem?

 

I am attching my Activity class file in which I have commented earlier integration part and added new as per guide line...

public class XRActivity extends QCARPlayerNativeActivity {

	
	/**
	 * This will gives you access to QCAR UI View.
	 */
//	public static QCARUnityPlayer mQCARView = null;
	public static ViewGroup mQCARView = null;

	private Timer mViewFinderTimer = null;


	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		Log.i(UIBinding.TAG, "@@# XRActivity::onCreate()");
		startService(new Intent(XRActivity.this, LocationUpdateService.class));
		// Instantiating UIBinding class for it's single ton instance
		new UIBinding(this); 


		Handler handler = new Handler();
        Runnable runnable = new Runnable() 
        {
            public void run() 
            {
                ViewGroup rootView = (ViewGroup) XRActivity.this.findViewById(android.R.id.content);
                 
                // find the first leaf view (i.e. a view without children)
                // the leaf view represents the topmost view in the view stack
                 
                View topMostView = getLeafView(rootView);
                  
                // let's add a sibling to the leaf view
                mQCARView = (ViewGroup) topMostView.getParent();
//                ViewGroup leafParent = (ViewGroup) topMostView.getParent();
                
//                Button sampleButton = new Button(XRActivity.this);
//                sampleButton.setText("Press Me");
//                leafParent.addView(sampleButton, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
            }
        };
 
        handler.postDelayed(runnable, 500);
	}

	private View getLeafView(View view) 
    {
        if (view instanceof ViewGroup) 
        {
            ViewGroup vg = (ViewGroup)view;
             
            for (int i = 0; i < vg.getChildCount(); ++i) 
            {
                View chview = vg.getChildAt(i);
                View result = getLeafView(chview);
                 
                if (result != null) 
                    return result;
            }
 
            return null;
        }
        else
        {
            DebugLog.LOGE("XRActivity::Found leaf view");
            return view;
        }
    }
	
	
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		
//		super.onKeyDown(keyCode, event);
		
		Log.i(UIBinding.TAG, "@@# XRActivity::onKeyDown onBackPressed   " +"UIBinding.mainScreen  " +UIBinding.mainScreen);
		if(UIBinding.mainScreen != null)
			return UIBinding.mainScreen.onKeyDown(keyCode, event);
		else if(UIBinding.tutorialScreen != null)
			return UIBinding.tutorialScreen.onKeyDown(keyCode, event);
		else
			return false;
	}
	
	@Override
	public void onStop() {
		
		Log.v(UIBinding.TAG, "@@# XRActivity::onStop()");
		
		if(UIBinding.mainScreen != null)
			UIBinding.mainScreen.onStop();
	}

	@Override
	public void onDestroy() {
		
		Log.v(UIBinding.TAG, "kkk @@# XRActivity::onDestroy()");
		super.onDestroy();
		

		if(UIBinding.mainScreen != null)
			UIBinding.mainScreen.onDestroy();
	}

	@Override
	public void onStart() {
		super.onStart();
		if(UIBinding.mainScreen != null)
			UIBinding.mainScreen.onStart();

	}

	
	@Override
	public void onResume() {
		super.onResume();
		QCAR.onResume();
		

		Log.v(UIBinding.TAG, "@@# XRActivity::onResume()");

//		if (mQCARView == null) {
//			// search the QCAR view
//			mViewFinderTimer = new Timer();
//			mViewFinderTimer.scheduleAtFixedRate(new QCARViewFinderTask(),
//					1000, 1000);
//		}
		
		if(UIBinding.mainScreen != null)
			UIBinding.mainScreen.onResume();
		
		UnityPlayer.UnitySendMessage("MessageReciever", "OnResumeCalledFromNative", "");
	}

	@Override
	public void onPause() {
		Log.v(UIBinding.TAG, "@@# XRActivity::onPause()");
		
        QCAR.onPause();
        
		if (mViewFinderTimer != null) {
			mViewFinderTimer.cancel();
			mViewFinderTimer = null;
		}
		
		if(UIBinding.mainScreen != null){
			
			UIBinding.mainScreen.onPause();
		}
		
	}

//	class QCARViewFinderTask extends TimerTask {
//		public void run() {
//			XRActivity.this.runOnUiThread(new Runnable() {
//				public void run() {
//					//Log.v(UIBinding.TAG, "@@# XRActivity::run() of TimerTask");
//					if (!QCAR.isInitialized())
//						return; // wait for QCAR init
//					if (mQCARView != null)
//						return;// already found, no need to search
//					// else search
//					View rootView = XRActivity.this.findViewById(android.R.id.content);
//					QCARUnityPlayer qcarView = findQCARView(rootView);
//					// if QCAR view has been found, add some android view/widget
//					// on top
//					if (qcarView != null) {
//						mQCARView = qcarView;
//					}
//					
//				}
//			});
//		}
//
//		private QCARUnityPlayer findQCARView(View view) {
//
//			Log.v(UIBinding.TAG, "@@# XRActivity::findQCARView():view=" + view);
//			if (view instanceof QCARUnityPlayer) {
//				return (QCARUnityPlayer) view;
//			}
//			if (view instanceof ViewGroup) {
//				ViewGroup vg = (ViewGroup) view;
//				for (int i = 0; i < vg.getChildCount(); ++i) {
//					QCARUnityPlayer foundView = findQCARView(vg.getChildAt(i));
//					if (foundView != null)
//						return foundView;
//				}
//			}
//			return null;
//		}
//	}
	
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		Util.isSharing = false;
		
		
		Log.i("", "kkk resultCode: " + requestCode);
		if (data != null) {
			Uri uri = data.getData();

			if (uri != null) {
				Cursor c = null;
				try {
					c = UIBinding._Activity.getContentResolver()
							.query(uri,
									new String[] {
											ContactsContract.CommonDataKinds.Phone.NUMBER,
											ContactsContract.CommonDataKinds.Phone.TYPE },
									null, null, null);

					if (c != null && c.moveToLast()) {
						String number = c.getString(0);
						Log.i("", "kkk number: " + number);
						ShareMessagePopUp.appendContactNumber(number);
					}
				} finally {
					if (c != null) {
						c.close();
					}
				}
			}
		}
	}

	
	
}

 

After updating sdk to vuforia-unity-android-ios-3-0-9 from 2-8-9

December 24, 2014 - 3:46am #4

;-)

After updating sdk to vuforia-unity-android-ios-3-0-9 from 2-8-9

December 24, 2014 - 3:22am #3

Thanks for reply :-)

 

Actually earlier my manifest was like this

<activity android:name="com.mobiware.xr.java.XRActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:windowSoftInputMode="adjustPan">
      
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
   <activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    </activity>
    <activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerNativeActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
     <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" /> 
     </activity> 

 

And it should be now

<activity android:name="com.mobiware.xr.java.XRActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:windowSoftInputMode="adjustPan">
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>

 

Problem is, I was using  <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" /> tag with QCARPlayerNativeActivity earlier, now that should be with my activity XRActivity which is now extending by QCARPlayerNativeActivity. And no need to declare it as separete activity in manifest.

 

Anyway, thanks :-)

 

After updating sdk to vuforia-unity-android-ios-3-0-9 from 2-8-9

December 24, 2014 - 12:01am #2

The events need to be dispatched, so you probably simply need to set the ForwardNativeEventsToDalvik to true in the AndroidManifest.xml, by adding these lines:

<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik"
android:value="true" />
 
Topic locked