Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Code for Android Unity App and the Intent Trouble Article on GetSocial Blog
package im.getsocial.sdk.core.unity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import im.getsocial.sdk.core.GetSocial;
import im.getsocial.sdk.core.util.Log;
* Created by tarasleskiv on 29/01/16.
* This activity is created because we cannot get Activity.onNewIntent callback in Unity when the app is running in background.
* When the app is running in background and opened from e.g. browsers intent url, this activity intercepts the intent and forwards in to GetSocial.
public class GetSocialDeepLinkingActivity extends Activity
private static String TAG = "GetSocial GetSocialDeepLinkingActivity";
protected void onCreate(Bundle savedInstanceState) {
Log.v(TAG, "Forward the intent");
Log.v(TAG, "Returning to main activity");
//start main activity
Intent newIntent = new Intent(this, getMainActivityClass());
private Class<?> getMainActivityClass() {
String packageName = this.getPackageName();
Intent launchIntent = this.getPackageManager().getLaunchIntentForPackage(packageName);
try {
return Class.forName(launchIntent.getComponent().getClassName());
} catch (Exception e) {
Log.e(TAG, "Unable to find Main Activity Class");
return null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.