I'm trying to use vuforia with some native .jar plugins for android in Unity. The problem has been in the manifest vuforia is the main activity and launcher, and nearly all the "native" android plugins also want to be the main activity in the manifest.
I understand that you can't have two "firsts" so one has to be the main, and I have to be able to startactivity() on the other when I want to use it...?
I've gone through the basic tutorials in google docs for making 2 activities, and passing a message to a display activity, but still can't figure out how to apply it to my situation with 2 existing 3rd part plugins.
I've got eclipse and all the java pre-requisite files/programs for android dev, along with the JD-GUI java decompiler to get the source from the unity .jar "plugins".
For Vuforia, I found a source java class that says you can edit it to work with other native plugins, but I can't figure out what I need to add, or in which method...
package com.qualcomm.QCARUnityPlayer;
import android.app.Dialog;
import android.app.NativeActivity;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import com.unity3d.player.UnityPlayer;
/** This custom NativeActivity shows how to initialize QCAR together with Unity from an activity.
* If you need to integrate another native library, you can modifiy this code and
* compile it to a JAR file to replace QCARUnityPlayer.jar in Assets/Plugins/Android
* */
public class QCARPlayerNativeActivity extends NativeActivity {
private QCARPlayerSharedActivity mQCARShared;
protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code
// UnityPlayer.init() should be called before attaching the view to a layout - it will load the native code.
// UnityPlayer.quit() should be the last thing called - it will unload the native code.
protected void onCreate (Bundle savedInstanceState){
requestWindowFeature(Window.FEATURE_NO_TITLE);
mUnityPlayer = new UnityPlayer(this);
super.onCreate(savedInstanceState);
// initialize QCAR asynchronously
mQCARShared = new QCARPlayerSharedActivity();
int gles_mode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
mQCARShared.onCreate(this, gles_mode, new UnityInitializer());
getWindow().takeSurface(null);
setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
getWindow().setFormat(PixelFormat.RGB_565);
if (mUnityPlayer.getSettings ().getBoolean ("hide_status_bar", true))
getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
private class UnityInitializer implements QCARPlayerSharedActivity.IUnityInitializer
{
public void InitializeUnity()
{
int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
boolean trueColor8888 = false;
mUnityPlayer.init(glesMode, trueColor8888);
View playerView = mUnityPlayer.getView();
setContentView(playerView);
playerView.requestFocus();
}
}
protected void onDestroy ()
{
mQCARShared.onDestroy();
mUnityPlayer.quit();
super.onDestroy();
}
// onPause()/onResume() must be sent to UnityPlayer to enable pause and resource recreation on resume.
protected void onPause()
{
super.onPause();
mUnityPlayer.pause();
mQCARShared.onPause();
}
protected void onResume()
{
super.onResume();
mQCARShared.onResume();
mUnityPlayer.resume();
}
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
mUnityPlayer.configurationChanged(newConfig);
}
public void onWindowFocusChanged(boolean hasFocus)
{
super.onWindowFocusChanged(hasFocus);
mUnityPlayer.windowFocusChanged(hasFocus);
}
public boolean dispatchKeyEvent(KeyEvent event)
{
if (event.getAction() == KeyEvent.ACTION_MULTIPLE)
return mUnityPlayer.onKeyMultiple(event.getKeyCode(), event.getRepeatCount(), event);
return super.dispatchKeyEvent(event);
}
}
This is the java code for the plugin I'm trying to get working with vuforia:
package com.devfo.andutils;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
public class DevfoSms {
private Context _context;
public DevfoSms(DevfoUnityPlayerActivity context){
this._context = context;
}
public void launchSmsActivity(){
launchSmsActivity(null, null);
}
public void launchSmsActivity(String number){
launchSmsActivity(number, null);
}
public void launchSmsActivity(String number, String body){
Intent smsIntent = new Intent("android.intent.action.SENDTO");
smsIntent.setType("vnd.android-dir/mms-sms");
if (number != null) {
smsIntent.setData(Uri.parse("sms:" + number));
}
if (body != null) {
smsIntent.putExtra("sms_body", body);
}
this._context.startActivity(smsIntent);
}
}
Then in the manifests I have a couple issues, the package names are different:
package="com.qualcomm.QCARUnityPlayer"
package="com.devfo.andutils"
And these are the 2 activities that are conflicting..........
<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="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and...
<activity
android:name="com.devfo.andutils.DevfoUnityPlayerActivity"
android:label="@string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Can I have 2 package names, or omit one? Can anyone point me in the right direction???? I tried to find someone to hire and the only person who responded wanted $1800 and then never responded back. I think I have the pieces I need, but am stuck...