- Home /
How to launch unity android app on startup?
I have seen similar questions but I can't get it working, either because I lack some basic knowledge or because I am missing in between steps.
I have also checked the plug in build manual and found no answer, it exposes several methods to execute native code, using DLLs, using "androidJavaObjects" created in c# scripts and using java classes. This third method seemed the simpler so I went with it. This is what I have done:
-Create in the Plugins folder and Android folder, placed this AndroidManifest.xml there: http://schemas.android.com/apk/res/android">
<uses-permission android:name="com.test.app.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application android:label="@string/app_name">
<receiver android:name="ReceiverOnBoot" android:enabled="true"
android:exported="true" android:label="com.InteractionFactory.startingtest.ReceiverOnBoot">
<intent-filter>
<action android:name="android.intent.action.REBOOT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
-Create an "ReceiverOnBoot.java" file with those contents pakage com.InteractionFactory.startingtest;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class ReceiverOnBoot extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent)
{
intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("market://details?id="+packageName));
startActivity(intent);
}
}
I have tried replacing the "onReceive" function contents with "Toast.makeText(context, "TEXT TO DISPLAY", Toast.LENGTH_LONG).show();" for debug purposes, to no effect.
Also, since I added those files no icon is created when I install the apk.
Do I need to compile the "java" file in any way? Build "jar" files maybe?
This doesn't seem like a Unity question to me. I think you might find more help if you asked elsewhere.
Answer by petur · Jan 17, 2018 at 12:25 PM
No, I ended up using 3rd party software to launch my app.
Your answer
Follow this Question
Related Questions
UnityPlayerActivity vs. UnityPlayerNativeActivity 0 Answers
How to write a java lib for unity as a plugin to make run another android app? 1 Answer
Android build failes because of manifest 0 Answers
How can I set/get/confirm the API used for an embedded Android script? 0 Answers
How to extend UnityPlayerActivity 0 Answers