Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by abhinandand91 · May 09, 2016 at 06:32 AM · unity 5pluginsapplicationandroidpluginandroid-manifest

How To implement App-indexing feature in to Android Game. ?

Hi, Currently our team is trying to enable App indexing and Autocomplete features in my Android game , for that we created an Sample Android App and tried to implement the App indexing as well as deep-linking .

In Android app side it worked properly. we tested the deep linking with following link

https://developers.google.com/app-indexing/android/test#test-autocompletions

And we tested Autocomplete in App by following link

https://codelabs.developers.google.com/codelabs/app-indexing/#0

so Both works correctly on App side .. And i would like to specify that we have created an Android studio project with the same Package ID as our Unity Project .. Followed all the steps mentioned in Unity's Android Plugin Manual.

For More details i am Including My Java source code...

 public class AppIndexingActivity extends UnityPlayerActivity    // AppCompactActivity is used in Studio App side 
 {
 
     private static AppIndexingActivity sInstance;
     private GoogleApiClient mClient;
     private String mUrl;
     private String mTitle;
     private String mDescription;
 
     public static AppIndexingActivity GetInstance()
     {
         if(sInstance == null)
         {
             sInstance = new AppIndexingActivity();
         }
         return sInstance;
     }
 
 
     public int initFromUnity ()
     {
         return  15;
     }
 
     public void OnCreateCall(Activity currentActivity)
     {
         mUrl ="android-app://com.NNGames.starchef_android/https/play.google.com/store/apps/";
         mTitle = "Star Chef";
         mDescription = "Become a Master Chef and run your own restaurant";
         mClient = new GoogleApiClient.Builder(currentActivity).addApi(AppIndex.API).build();
     }
 
     public Action getAction()
     {
             Thing object = new Thing.Builder()
                     .setName(mTitle)
                     .setDescription(mDescription)
                     .setUrl(Uri.parse(mUrl))
                     .build();
 
             return new Action.Builder(Action.TYPE_VIEW)
                     .setObject(object)
                     .setActionStatus(Action.STATUS_TYPE_COMPLETED)
                     .build();
     }
 
     public  void  OnStartCall()
     {
             mClient.connect();
             PendingResult<Status> result = AppIndex.AppIndexApi.start(mClient,getAction());
             result.setResultCallback(new ResultCallback<Status>()
             {
                 @Override
                 public void onResult(@NonNull Status status)
                 {
                     if(status.isSuccess())
                     {
                         Log.d(AppIndexingActivity.class.getName(),"App Indexing API Recorded page"+ mTitle +"view successfully.");
                     }
                     else
                     {
                         Log.e(AppIndexingActivity.class.getName(),"App Indexing API: There was an error recording the page view."+status.toString());
                     }
                 }
             });
     }

My manifest file is as follows ..

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.NNGames.starchef_android">
 
     <uses-permission android:name="android.permission.INTERNET"/>
 
     <application
         android:allowBackup="true"
         android:label="@string/app_name"
         android:theme="@style/AppTheme"
         android:icon="@mipmap/ic_launcher"
         android:supportsRtl="true">
 
         <activity android:name=".AppIndexingActivity">
 
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
 
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="android.intent.category.BROWSABLE" />
                 <data android:scheme="android-app">
                 </data>
             </intent-filter>
 
         </activity>
         <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
         <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
         
     </application>
 
 </manifest>

The way i am using the plugins.

 using UnityEngine;
 using System.Collections;
 
 public class AndroidEnableAppIndexing : MonoBehaviour
 {
     
     AndroidJavaObject mAppIndexingActivity;
     AndroidJavaObject mCurrentActivity;
 
 
     void Awake ()
     {
         DontDestroyOnLoad(this.gameObject);
         Debug.Log ("In Awake");
         #if !UNITY_EDITOR
         AndroidJavaClass unity = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
 
         mCurrentActivity = unity.GetStatic<AndroidJavaObject> ("currentActivity");
 
         AndroidJavaClass appIndexingClass = new AndroidJavaClass ("com.NNGames.starchef_android.AppIndexingActivity");
 
         mAppIndexingActivity = appIndexingClass.CallStatic<AndroidJavaObject> ("GetInstance");
 
         mAppIndexingActivity.Call ("OnCreateCall",mCurrentActivity);
 
         #endif
     }
 
     void Start()
     {
         Debug.Log ("In Start");
         #if !UNITY_EDITOR
         mAppIndexingActivity.Call ("OnStartCall");
         #endif
     }
         
 
     void OnApplicationQuit() 
     {
         Debug.Log("Application is going to quit.");
         #if !UNITY_EDITOR
         mAppIndexingActivity.Call ("OnStopCall");
         #endif
     }
         
 }
 

I included the Jar file and the manifest file in to my Unity project. when i run my game and try to check logs i get an No such static method java language Exception. as follows . alt text

Why is shows such behaviour when i include App indexing apis ?, When i comment the App indexing api's the plugin calls the method properly. Is there any other way to include App indexing Api's in to Unity Game app ?

Thank You.

screen-shot-2016-05-04-at-125242-pm.png (43.7 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

81 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to use gradle's buildTypes, productFlavors, sourceSet and other features to batch build apks for different android channel in unity 0 Answers

Unity detect wrong androidSDK version 0 Answers

Android build problem 0 Answers

DLL found in editor but not in build version 2 Answers

CommandInvokationFailure: Gradle build failed. Unity Build 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges